Post

Need advice from my React devs out there . I need to load a Zustand store with a bunch of data from an API. Should I just do that directly in the store using an async function or inject the data? The goal is maintainability. Would love examples if anyone has any.

0 reposts0 likes

If you can guarantee that the data is available on page load and you're not ever going to move to a serverless architecture, injecting the data into a variable on the initial page render is better. Otherwise you are going to have to defer initializing your store until the asyc is finished. Not ideal