[Bug]: The OneSignal web SDK can only be initialized once. Extra initializations are ignored. Please remove calls initializing the SDK more than once.
SneakingSlayer opened this issue · 1 comments
SneakingSlayer commented
What happened?
The package seems to be throwing this new error:
OneSignal: The OneSignal web SDK can only be initialized once. Extra initializations are ignored. Please remove calls initializing the SDK more than once.
Regardless of how you initialize OneSignal.
Code below:
const [isInitializedOneSignal, setIsInitializedOneSignal] = useState(false);
const initOneSignal = useCallback(async () => {
// If OneSignal is already initialized then return
if (isInitializedOneSignal) {
return;
}
// Initialize OneSignal
await OneSignal.init({
appId: 'MY-APP-ID',
allowLocalhostAsSecureOrigin: true
});
setIsInitializedOneSignal(true);
// Open subscribe prompt
OneSignal.Slidedown.promptPush();
}, [isInitializedOneSignal]);
// Initialize One Signal
useEffect(() => {
void initOneSignal();
},[initOneSignal]);
What browsers are you seeing the problem on?
Firefox, Chrome (Chromium), Safari, Microsoft Edge, Opera, Brave
What operating system are you running?
asdasasdasasdasasdasasdas
Steps to reproduce?
1. Initialize OneSignal
2. Run the app
What did you expect to happen?
Should not throw any errors
Relevant log output
No response
SneakingSlayer commented
Just realized React's StrictMode renders everything twice hence this error.