-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 18 in concurrent mode + Cache provider #1904
Comments
Hey, this breaks us pretty bad too. Had to create a workaround using middlewares for my use-case (persistance) but it's far from perfect. |
Any workarounds I know of is downgrading react to v17 or swr to v1.1. |
React 18 support will be our top priority for 2.0 and it’s in the works. |
This should works in latest beta version now. |
@promer94
I have no idea what's going on |
@piotr-cz could you try to refresh the page. I had same problem but works after reloading page. I think it might be some cache problem of codesandbox. |
@promer94 right click into result page -> Reload Frame |
Great! I guess we can close this issue now? 😁 |
Bug report
Description / Observed Behavior
When using React 18 in concurrent mode and a custom cache provider, an error is thrown:
This happens when using create-react-app v4 or v5 in dev mode (
react-scripts start
), however not when running an actual build (react-scripts build
).Expected Behavior
No error is thrown
Repro Steps / Code Example
CodeSandbox based on Basic usage is available here: https://codesandbox.io/s/eager-alex-zyijly?file=/src/index.js:
ReactDOM.createRoot(rootElement).render(...)
)const provider = () => new Map();
<App />
with<SWRConfig value={{ provider }}></SWRConfig>
Additional Context
SWR version: 1.1.0 ... 1.3.0 || 2.0.0-beta.0 || 2.0.0-beta.1
Latest version with no error: 1.0.1
It looks like the
SWRGlobalState
WeakMap in theuseSWRHandler
function doesn't contain custom cache provider, even that it has been successfully added ininitCache
function.The text was updated successfully, but these errors were encountered: