I am building a web app with nextjs.
I am having trouble.
The sign_up component under the pages directory is not rendered.
It is a blank page.
I looked up the details in the chrome extension and got this warning.
Unhandled Runtime Error
Error: Maximum update depth exceeded.
This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
React limits the number of nested updates to prevent infinite loops.
The following is the index.tsx file under components/SignUp directory.
// SignUp/index.tsx
import type { FC } from "react";
export const SignUp: FC = () => {
return (
<>
<h1>user registration</h1>
</>
);
};
The forrowing is the sign_up component under the pages directory.
pages/sign_up.tsx
import { SignUp } from "../components/SignUp";
import { Layout } from "src/layouts/Layout";
const SignUpPage = () => {
<>
<Layout pageTitle="Sign Up">
<SignUp />
</Layout>
</>
};
export default SignUpPage;
The following is file structure.
.
└── frontend/
└── src/
├── api
├── components/
│ ├── Dashboard
│ ├── Login
│ ├── MyTodo
│ └── SignUp/
│ ├── index.tsx
│ └── schema.ts
├── layouts
├── pages/
│ ├── _app.tsx
│ ├── _error.tsx
│ ├── 404.tsx
│ ├── dashboard.tsx
│ ├── index.tsx
│ ├── my_todo.tsx
│ └── sign_up.tsx
├── styles
└── util
Although it is displayed in the image,
The my_todo page, which was created with a similar structure (only h1 tag and form), displayed without problems.
I wonder why. If anyone knows, please let me know.
2
Answers
i think have SignUpPage component in the return statement is not returning the JSX. try with this corrected version:
Hope this will help for you.
The issue is that in your
sign_up.tsx
file, you are missing thereturn
. It should be like this:Furthermore, you are using fragments unnecessarily. You can simplify the code by removing them and just return the JSX like so:
Check out the docs here to read more about them.