#Problem when running yarn dev

1 messages · Page 1 of 1 (latest)

ionic fableBOT
#

Hi @cedar nexus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

It seems like the issue is related to accessing the data property of settings in your layout.js file. Based on the provided extracts, I can't find the exact cause of the issue. However, I can suggest a way to handle the undefined settings object to prevent the error.

In your layout.js file, you can add a conditional check to ensure that settings and settings.data are defined before accessing their properties. Here's an example of how you can modify your Layout component:

export default function Layout(pageProps) {
  const { settings } = pageProps;

  // Check if settings and settings.data are defined
  const info_title = settings && settings.data ? settings.data.info_title : '';
  const info_content = settings && settings.data ? settings.data.info_content : '';
  const address = settings && settings.data ? settings.data.address : '';
  const copyright = settings && settings.data ? settings.data.copyright : '';
  const mail = settings && settings.data ? settings.data.mail : '';
  const phone = settings && settings.data ? settings.data.phone : '';
  const social_media = settings && settings.data ? settings.data.social_media : '';

  return (
    <>
      <div className="grow shrink basis-full">{pageProps.children}</div>
      <Footer
        info_title={info_title}
        info_content={info_content}
        address={address}
        copyright={copyright}
        mail={mail}
        phone={phone}
        social_media={social_media}
      />
    </>
  );
}

This way, if settings or settings.data are undefined, the component will still render without throwing an error.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@cedar nexus kapa.ai is still learning and improving, please let us how it did by reacting below

cedar nexus
#

@ionic fable settings is not undefined, it works when running yarn dev, but I still get the error

ionic fableBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Hmm, I don't know enough to give you a confident answer yet. However, I recommend reviewing the Next.js documentation (https://nextjs.org/docs) for more information on handling data and props in your components.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Get started with Next.js in the official documentation, and learn more about all our features!