Skip to content

Commit 9af279b

Browse files
author
Heiner Pöpping
committed
🐛 Improve error reporting and stability in ChaynsProvider
1 parent 58eefc0 commit 9af279b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/components/ChaynsProvider.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ const ChaynsProvider: React.FC<ChaynsProviderProps> = ({
4848
if (data && functions) {
4949
customWrapper.current = new ModuleFederationWrapper(data, functions, customFunctions);
5050
} else {
51-
console.warn('ModuleFederationWrapper requires data and functions');
51+
console.error('[chayns-api] ModuleFederationWrapper requires data and functions');
5252
}
5353
} else if (isServer) {
5454
if (data && functions) {
5555
customWrapper.current = new SsrWrapper(data, functions, customFunctions);
5656
} else {
57-
console.warn('SsrWrapper requires data and functions');
57+
console.error('[chayns-api] SsrWrapper requires data and functions');
5858
}
5959
} else {
6060
const deviceInfo = getDeviceInfo(navigator.userAgent, '');
@@ -66,8 +66,10 @@ const ChaynsProvider: React.FC<ChaynsProviderProps> = ({
6666
}
6767
}
6868
moduleWrapper.current = customWrapper.current;
69-
chaynsApis[idRef.current] = customWrapper.current.functions;
70-
customWrapper.current.chaynsApiId = idRef.current;
69+
if (customWrapper.current) {
70+
chaynsApis[idRef.current] = customWrapper.current.functions;
71+
customWrapper.current.chaynsApiId = idRef.current;
72+
}
7173
}
7274

7375
const [isInitialized, setIsInitialized] = useState<boolean>(!!customWrapper.current?.values);

0 commit comments

Comments
 (0)