Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Next.js Components: Error: error: Return statement is not allowed here

I am running into an error when I add a new component into my Next.js Project where it gives the following:

`./components/GridMember.js
Error: error: Return statement is not allowed here

|
6 | return (test);
| ^^^^^^^^^^^^^^^^^^^^^^^^^

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Caused by:
0: failed to process js file
1: error was recoverable, but proceeding would result in wrong codegen
2: Syntax Error`

[error][1]
[1]: https://i.stack.imgur.com/PU5z5.png

I am unsure what is causing this as I should be able to return what I have. I have pasted the code below to the component

`import styles from ‘./GridMember.module.css’

export default GridMember()
{
    return (<div>test</div>);
}`

and then the page has the following:

`import GridMember from "../components/GridMember";

export default function Work()
{
    return(
    <div>WORKING
        <GridMember/>
    </div>
    );
}`

Any suggestions are appreciated!

>Solution :

you are missing function
so you must write the code like this

import styles from './GridMember.module.css'


export default function GridMember()
{
    return (<div>test</div>);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading