A
A
Andrey Okhotnikov2019-06-06 12:38:26
React
Andrey Okhotnikov, 2019-06-06 12:38:26

'Circular structure' error when running on server?

NEXTJS - when starting a local server, everything works, but when running on a remote test server, I get an error

Circular structure in "getInitialProps" result of page "/home". https://err.sh/zeit/next.js/circular-structure

The code
Home.getInitialProps = async ({ reduxStore, query }) => {
  const type = query.type || reduxStore.getState().app.type;
  await reduxStore.dispatch(initPage(query));

  return {
    namespacesRequired: ['common'],
    type
  };
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-06
@tsepen

See the contents of store. You either write cyclic data structures there, or write some third-party library object containing such data.
If you write your own helper in the store that uses third-party libraries, which is re-created on the client, then implement the toJSON method in it:

toJSON() {
  return '[Helper Name]';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question