jeudi 22 octobre 2020

Jest tests passed but get an Error: Error serializing `symbol` returned from `getStaticProps` when returning JSX.Element

Here is the code:

export const getStaticProps: GetStaticProps = async (context) => {
  const greeting = <DateFC date={new Date()} />;
  const saved_locations: JSX.Element[] = [];
  return {
    props: {
      greeting: greeting,
      saved_locations: saved_locations,
    },
  };
};

and the error

Server Error
Error: Error serializing `.greeting.$$typeof` returned from `getStaticProps` in "/".
Reason: `symbol` cannot be serialized as JSON. Please only return JSON serializable data types.

This error happened while generating the page. Any console logs will be displayed in the terminal window.

I'm using the NextJs react framework.

Aucun commentaire:

Enregistrer un commentaire