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

RFC: React 19 support #340

Open
felsteadd opened this issue Jan 7, 2025 · 10 comments
Open

RFC: React 19 support #340

felsteadd opened this issue Jan 7, 2025 · 10 comments

Comments

@felsteadd
Copy link

felsteadd commented Jan 7, 2025

Is your feature request related to a problem? Please describe.
Support for React 19 is needed now that React 19 has been released.

Describe the solution you'd like
Add support for React 19

Describe alternatives you've considered
Overrides in package.json

Additional context
Following the upgrade steps at https://react.dev/blog/2024/04/25/react-19-upgrade-guide:

npm install --save-exact react@^19.0.0 react-dom@^19.0.0

image

Caused by:

npm install --save-exact @types/react@^19.0.0 @types/react-dom@^19.0.0

image

Caused by:

@studiosciences
Copy link

I tried to open a PR with this but there were many failing tests. I'm not sure if this was because of changes in React, or if it's related to changes in the the deprecated react-test-renderer.

Test Suites: 3 failed, 3 passed, 6 total
Tests:       33 failed, 59 passed, 92 total
Snapshots:   5 failed, 1 passed, 6 total

@felsteadd
Copy link
Author

I tried to open a PR with this but there were many failing tests. I'm not sure if this was because of changes in React, or if it's related to changes in the the deprecated react-test-renderer.

Test Suites: 3 failed, 3 passed, 6 total
Tests:       33 failed, 59 passed, 92 total
Snapshots:   5 failed, 1 passed, 6 total

@studiosciences I think you are correct - the test failures are related to the deprecation of react-test-renderer. Some tests can easily be fixed up switching to render from @testing-library/react as long as the jest snapshots are updated but some of the other tests will need a more significant refactor I think.

@felsteadd
Copy link
Author

Some of the test failures can be solved as follows:

test('ld client is initialised correctly with deprecated user object', async () => {
    const user: LDContext = { key: 'yus' };
    const props: ProviderConfig = { clientSideID, user };
    const LaunchDarklyApp = (
      <LDProvider {...props}>
        <App />
      </LDProvider>
    );

    // Replace create with render from testing-library/react and wrap in act imported from React
    await act(()=> render(LaunchDarklyApp));

    expect(mockInitialize).toHaveBeenCalledWith(clientSideID, user, options);
  });

@studiosciences
Copy link

studiosciences commented Jan 13, 2025

@felsteadd I've done extensive research into this act() > render() interaction. They say that render() is already handles act() internally. However, as far as I can tell, if any mocked async processes are triggered with a useEffect(), then the additional wrapper act() may catch them and suppress the warnings. Is that the case here?

Any later useEffect() calls that may be triggered by the first still create the act() warning. It's all super annoying.

@felsteadd
Copy link
Author

@felsteadd I've done extensive research into this act() > render() interaction. They say that render() is already handles act() internally. However, as far as I can tell, if any mocked async processes are triggered with a useEffect(), then the additional wrapper act() may catch them and suppress the warnings. Is that the case here?

Any later useEffect() calls that may be triggered by the first still create the act() warning. It's all super annoying.

Yeah it is not clear to me either. I have raised a support ticket with LaunchDarkly and it has been escalated to the engineering team for assessment and resolution.

@louis-launchdarkly
Copy link
Contributor

Hello @felsteadd and @studiosciences, thank you for raising this request this is on top of the engineering team's backlog (and a top support request). I am sorry that this is not as fast as you all hope and I can't provide an ETA yet.

We are really thankful for the discussion and suggestions in this thread, which will help the SDK team address this faster. If you notice anything else that could help resolve the upgrade issue, please feel free to add to this thread.

@danieldelarosaagility
Copy link

+1

@studiosciences
Copy link

3.6.1 is released with ^19.0.0 as a peer dependency. Internally, it's still using React 18 for development and testing.

@louis-launchdarkly
Copy link
Contributor

@studiosciences Yes, I just double-checked that the typescript example app bumped to React 19 as the dependency, it runs correctly using the published 3.6.1 package to unblock people stuck on the dependency.

But I think this doesn't address everything listed on this thread, so I am trying to see what else is needed - is the missing part bumping all the other react dependencies in places like the root package.json and examples all to 19, or something else as you and @felsteadd mentioned there are multiple test failures.

@felsteadd
Copy link
Author

@studiosciences @louis-launchdarkly the latest published version still lists React 18 types as a dev dependency and still uses the deprecated react-test-renderer.

"react-test-renderer": "^18.0.0",
    "@types/react": "^18.0.3",
    "@types/react-dom": "^18.0.0",
    "@types/react-test-renderer": "^18.0.0",

You should address all these issues to fully support React 19 with TypeScript.

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

4 participants