koba04 / swr-devtools

A DevTool for SWR
https://swr-devtools.vercel.app
MIT License
221 stars 3 forks source link

Support SSR #86

Open sculove opened 2 years ago

sculove commented 2 years ago

I face the following message

error - ReferenceError: window is not defined
    at /Users/user/workspace/loan-web/node_modules/swr-devtools/src/createSWRDevTools.ts:88:5
    at Map.cache.set (/Users/user/workspace/loan-web/node_modules/swr-devtools/src/swr-cache.ts:23:7)

You need to support the ssr! Can you fix it?

koba04 commented 2 years ago

@sculove Thank you for your feedback! What versions of SWR and SWRDevTools do you use? Do you add into your application?

sculove commented 2 years ago

I saw the history of SSR-related issues resolved in the v1.1.1 release However, in npm, only version 1.0.0 was available.

this is my application codes

 <SWRDevTools>
    <SSRSWRConfig fallback={fallback} value={{fetcher: getClientAxios()}}>
        <RecoilRoot
            initializeState={({set}) => {
                set(loanUserState, {
                    type,
                    loanPathType,
                })
            }}>
            <UserAgentProvider userAgent={userAgent}>
                <AlertProvider>
                    <RenderByEnv Component={Component} pageProps={pageProps} />
                </AlertProvider>
                <GlobalErrorContainer />
            </UserAgentProvider>
        </RecoilRoot>
    </SSRSWRConfig>
</SWRDevTools>
koba04 commented 2 years ago

Thank you! I'll work on that.