Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React SDK doesn't load in React 18's StrictMode #221

Closed
TatarczykAVitesse opened this issue Dec 3, 2024 · 4 comments
Closed

React SDK doesn't load in React 18's StrictMode #221

TatarczykAVitesse opened this issue Dec 3, 2024 · 4 comments

Comments

@TatarczykAVitesse
Copy link

Hello

I've been trying to integrate Split in my app but the features would never load (isReady property is never set to true) and it turned out it's because in the development mode I'm using React's StrictMode. As soon as I moved the SplitFactoryProvider outside of it, everything starts to work properly.

I prepared a reproduction repo based on the React's example app https://github.com/TatarczykAVitesse/react-typescript-sdk-examples

Interestingly, as soon as I downgrade from version 2 to version 1 of @splitsoftware/splitio-react, it starts to work with no further changes

@EmilianoSanchez
Copy link
Contributor

EmilianoSanchez commented Dec 3, 2024

Hi @TatarczykAVitesse,

We will include a fix for this in the next release. The fix has already been developed here: #217

In the meantime, you can try a release candidate that includes a fix: "@splitsoftware/splitio-react": "^2.0.1-rc.0",
or consider passing the factory instance rather than the config object to the SplitFactoryProvider:

import {SplitFactoryProvider, SplitFactory} from '@splitsoftware/splitio-react';
...

const sdkFactory = SplitFactory(sdkConfig);

root.render(
  <StrictMode>
    <SplitFactoryProvider factory={sdkFactory}>
      <App />
    </SplitFactoryProvider>
  </StrictMode>
);

I will keep the issue open, let you know, and then close it when the release is done :)

Thanks for sharing!

@EmilianoSanchez
Copy link
Contributor

Hi @TatarczykAVitesse ,

I’m closing this issue for now, as we’ve just released React SDK v2.0.1, which includes the update to support React Strict Mode, among other improvements and bugfixes. Try this new version on your side.

Thanks again!

@MaxArnautFrontegg
Copy link

It's still reproducing for me on 2.0.1. isReady is never set to true...
For now stopped on 1.13.0 it works as expected.

@EmilianoSanchez
Copy link
Contributor

I am sorry to hear that @MaxArnautFrontegg.

I tried reproducing it on my side but wasn't able to. After updating @splitsoftware/splitio-react to 2.0.1 in https://github.com/TatarczykAVitesse/react-typescript-sdk-examples and running the app with StrictMode, isReady is set to true as expected.

So, I assume you are facing the issue in a different project. Could you please extend your example app to reproduce the issue with 2.0.1?

Looking forward to your example so we can investigate further!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants