bjoluc / next-redux-cookie-wrapper

Sync a subset of your Redux state with cookies in Next.js :cookie: :sparkles:
MIT License
114 stars 4 forks source link

Not working #21

Closed alessio-zamparelli closed 2 years ago

alessio-zamparelli commented 2 years ago

Hi, i'm using next-redux-cookie-wrapper on a project using also next-seo and next-auth. my _app.js is like

<SessionProvider
      // Provider options are not required but can be useful in situations where
      // you have a short session maxAge time. Shown here with default values.
      options={{
        // Stale Time controls how often the useSession in the client should
        // contact the server to sync the session state. Value in seconds.
        // e.g.
        // * 0  - Disabled (always use cache value)
        // * 60 - Sync session state with server if it's older than 60 seconds
        staleTime: 0,
        // Refetch Interval tells windows / tabs that are signed in to keep sending
        // a keep alive request (which extends the current session expiry) to
        // prevent sessions in open windows from expiring. Value in seconds.
        //
        // Note: If a session has expired when keep alive is triggered, all open
        // windows / tabs will be updated to reflect the user is signed out.
        refetchInterval: 0
      }}
      session={session}
    >
      {/* <Provider store={store}> */}
      <Layout {...Component.layoutProps}>
        <DefaultSeo {...SEO} />
        <Component {...pageProps} />
      </Layout>
      {/* </Provider> */}
    </SessionProvider>

The cookie is written in browser but i'm unable to reload the page retaining the data. Any idea?

simplenotezy commented 2 years ago

@alessio-zamparelli I have the same issue; I installed the package as per the readme. I notice that a cookie is set on my browser:

image

However, if I hit refresh the state is not populated with that cookie:

image

So I am quite curious on why thi is happening as well.

simplenotezy commented 2 years ago

I enabled debug, and I notice this in the console:

 4. WrappedApp created new store with withRedux(AppWithTranslation) { initialState: undefined, initialStateFromGSPorGSSR: undefined }
bjoluc commented 2 years ago

Hi @alessio-zamparelli and @simplenotezy, do you have getServerSideProps, getStaticProps, or getInitialProps on the page you load? If not, I guess this is a duplicate of #22...

bjoluc commented 2 years ago

I'm going to close this as a duplicate of #22 which has been fixed with v2.1.2. Please re-open if the problem persists!