Home > Back-end >  React.forwardRef() - Parsing error: Missing semicolon
React.forwardRef() - Parsing error: Missing semicolon

Time:08-30

I found an error after adding React.forwardRef() to my .JSX component file.

import React from 'react';
import classes from './MyInput.module.css';

const MyInput = React.forwardRef((props, ref)) => {

    return (
       <input className={classes.myInput} {...props} />
    );
};

export default MyInput;

Now I have this error:

ERROR in [eslint]

src\components\UI\inputs\MyInput.jsx

Line 4:46: Parsing error: Missing semicolon. (4:46)

CodePudding user response:

You are closing the parenthesis opened after React.forwardRef at the wrong place:

import React from 'react';
import classes from './MyInput.module.css';

const MyInput = React.forwardRef((props, ref) => {

    return (
       <input className={classes.myInput} {...props} />
    );
});

export default MyInput;
  • Related