pmndrs / zustand

🐻 Bear necessities for state management in React
https://zustand-demo.pmnd.rs/
MIT License
48.39k stars 1.5k forks source link

On Suspense #733

Closed phaistonian closed 2 years ago

phaistonian commented 2 years ago

Hello,

Since 18 is already here, I am wondering if there's any suggested - or "planned" - way for Zustand to work, the proper way, with Suspense.

Merry Christmas to you all! 🎉

dai-shi commented 2 years ago

Good question. Suspense for Data Fetching will still not be finalized in 18.0.0, so not sure if we can do anything officially. Besides, zustand library doesn't deal anything with async stuff at the moment. It will be something totally new concept. What would people expect with Suspense?

Merry Christmas!

dai-shi commented 2 years ago

In case somebody doesn't know, other two libs jotai and valtio support Suspense. So, there's something we can learn.

phaistonian commented 2 years ago

@dai-shi perhaps useSyncExternalStore is the proper way to go.

Our goal is for all subscription-based libraries to migrate their implementations to useSyncExternalStore.

dai-shi commented 2 years ago

Ah, you just mean to support React 18 in general.

550 has been there for 4 months. We will release v4 when everything is ready.

(https://github.com/reactwg/react-18/discussions/86 is open Aug 28 and #550 is created Aug 31 right after that even before uSES is actually implemented!) Stay tuned!