swr-devtools icon indicating copy to clipboard operation
swr-devtools copied to clipboard

Support SSR

Open sculove opened this issue 3 years ago • 3 comments

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?

sculove avatar Sep 27 '22 01:09 sculove

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

koba04 avatar Sep 27 '22 04:09 koba04

  • SWR: 1.3.0
  • SWRDevTools: 1.0.0

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>

sculove avatar Sep 27 '22 11:09 sculove

Thank you! I'll work on that.

koba04 avatar Sep 27 '22 15:09 koba04