Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Rendered more hooks than during the previous render. #175

Open
engineerwr opened this issue Dec 27, 2023 · 1 comment
Open

Error: Rendered more hooks than during the previous render. #175

engineerwr opened this issue Dec 27, 2023 · 1 comment

Comments

@engineerwr
Copy link

Hello gentlemen, I have a problem that I cannot solve.
it comes that whenever I add a second widget with usestate.
it returns me: Unhandled Runtime Error
Error: Rendered more hooks than during the previous render.

Does anyone have an idea how to get around this?
Stay safe and have a 2024 full of many achievements

@LeoMld
Copy link

LeoMld commented Feb 29, 2024

Hi, I also faced a similar problem, which I eventually linked to how I named my configuration file. At first, I named it config.ts, not realizing it should have been config.tsx. To get around the compilation error, I modified my approach, shifting from JSX syntax to a plain function invocation:

Originally, I had (config.ts):

{
  widgetName: 'default',
  widgetFunc: (props: any) => <DefaultWidget {...props} />,
}

But to avoid the error, I changed it to (config.ts):

{
  widgetName: 'default',
  widgetFunc: (props: any) => DefaultWidget(props),
}

This workaround led to another issue: "Rendered more hooks than during the previous render," which occurred after implementing useState within my widget. To resolve such problems, the correct approach is indeed to name your file config.tsx and use the JSX syntax as follows:

{
  widgetName: 'default',
  widgetFunc: (props: any) => <DefaultWidget {...props} />,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants