You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
and everything looks great; the app config is loaded in the browser, then if I move between pages or if I make changes to <Page /> the config is not loaded again (so the selector is caching as I would expect)
but if I make some change to the loadConfig function, NextJS does a HMR style refresh and my promise executes again - which is fair enough; recoil has rerun my promise function because the function body changed. But my page then just says 'loading' - the HMR has not told react to stop suspending
should I instead be storing the config in an atom and use a selector to run the promise and set the atom? Or should I be using an atom effect? I'm not sure if this is me using recoil wrong, or using react 18 / suspense wrong, or me setting up NextJS + React 18 wrong!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
I'm new to Recoil + Suspense, so I could definitely be doing something wrong. For reference, I'm using NextJS & the current RC of React 18.
My app is wrapped with
<Suspense fallback="loading"><Page /></Suspense>
I have this function which should load some app config json:
and this selector:
and my app looks like this:
and everything looks great; the app config is loaded in the browser, then if I move between pages or if I make changes to
<Page />
the config is not loaded again (so the selector is caching as I would expect)but if I make some change to the
loadConfig
function, NextJS does a HMR style refresh and my promise executes again - which is fair enough; recoil has rerun my promise function because the function body changed. But my page then just says 'loading' - the HMR has not told react to stop suspendingshould I instead be storing the config in an
atom
and use aselector
to run the promise and set the atom? Or should I be using an atom effect? I'm not sure if this is me using recoil wrong, or using react 18 / suspense wrong, or me setting up NextJS + React 18 wrong!any help is greatly appreciated :)
Beta Was this translation helpful? Give feedback.
All reactions