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 19 support #2318

Open
RobinClowers opened this issue May 15, 2024 · 10 comments
Open

React 19 support #2318

RobinClowers opened this issue May 15, 2024 · 10 comments

Comments

@RobinClowers
Copy link

It appears recoil does not work with the react 19 RC that came out today. I'm guessing this will not be resolved, since Meta has abandoned this project, but I'd love to be wrong!

TypeError: react__WEBPACK_IMPORTED_MODULE_0___default().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is undefined
    currentRendererSupportsUseSyncExternalStore index.js:511
    useRecoilValueLoadable index.js:5353
    useRecoilValue index.js:5372
@wojtekmaj
Copy link

It looks like replacing currentRendererSupportsUseSyncExternalStore body with return true does the trick. I mean, at this point it's probably better to migrate away from Recoil, but if you really, REALLY have to, then that could be a way to work around it.

@RobinClowers
Copy link
Author

@wojtekmaj thanks for chiming in! Definitely planning a migration, but nice to know there is an option if we want to defer it a bit.

@CarlosVergikosk
Copy link

It looks like replacing currentRendererSupportsUseSyncExternalStore body with return true does the trick. I mean, at this point it's probably better to migrate away from Recoil, but if you really, REALLY have to, then that could be a way to work around it.

Why would you say that at this point migration would be better? Thanks

@wojtekmaj
Copy link

wojtekmaj commented May 20, 2024

Why would you say that at this point migration would be better? Thanks

@CarlosVergikosk It's heartbreaking to say but I don't see Facebook is interested in keeping this project alive anymore. The latest version is broken in React Native (#2274), and has been for more than a year now.

At the same time, Recoil is no longer the only choice for using Suspense for Data Fetching and other, community-provided projects have not only caught to speed with Recoil, but surpassed it in terms of functionality, stability, maintainability, and community activity, the latter of which is a great factor for approximating project health.

Recoil was an amazing solution when it came out, but I'd advise anyone not to use it in new projects and consider migrating away from it in existing ones.

@CarlosVergikosk
Copy link

CarlosVergikosk commented May 20, 2024

Unfortunately i belive you are right @wojtekmaj, in terms of options to recoil, what would you suggest based on your experience?

Thanks for taking the time to contribute.

@wojtekmaj
Copy link

wojtekmaj commented May 20, 2024

Depends on your use case. Here's my first thought:

  • Global simple state -> Jotai
  • State machines -> Zustand
  • Network request-rich states -> Tanstack React Query

@XQY279
Copy link

XQY279 commented Jun 17, 2024

It looks like replacing currentRendererSupportsUseSyncExternalStore body with return true does the trick. I mean, at this point it's probably better to migrate away from Recoil, but if you really, REALLY have to, then that could be a way to work around it.

The modification was successful, but a new error has occurred: Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform

The source code generated by Recoil still contains many instances of React.createElement.

@haula-dv
Copy link

It appears recoil does not work with the react 19 RC that came out today. I'm guessing this will not be resolved, since Meta has abandoned this project, but I'd love to be wrong!

TypeError: react__WEBPACK_IMPORTED_MODULE_0___default().__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is undefined
    currentRendererSupportsUseSyncExternalStore index.js:511
    useRecoilValueLoadable index.js:5353
    useRecoilValue index.js:5372

I have a library can using like recoil https://www.npmjs.com/package/nes-zustand

@goodanthony
Copy link

goodanthony commented Jul 7, 2024

CarlosVergikosk, came across https://github.com/LegendApp/legend-state

Legend-State makes managing your app's data easier by ensuring only dependent components re-render, which boosts performance. It updates only the parts of your app that need it. With a simple setup and less repetitive code, it's great for React projects, offering an efficient way to handle state changes without the complexity of other tools. It's perfect for building responsive, high-performance apps.

@bowheart
Copy link

Just want to second the Jotai suggestion - it's the most popular Recoil alternative and has been around almost as long as Recoil. There's also Zedux, a newer lib with an atomic model that's closer to Recoil than Jotai's. Both these libs are newer, faster, and more full-featured than Recoil at this point. And I believe both already support React 19.

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

7 participants