'React' must be in scope when using JSX react/react-in-jsx-scope

Dung Do Tien Jan 24 2021 1449

I have created a component in my react project, when I run the project I got an error 'React' must be in scope when using JSX  react/react-in-jsx-scope

This is my component js file:

import Recipes from './Recipes';

const Navs = ({recipes}) => (
        <div className="recipes">
        {recipes.map((recipe, i)=>    
            <Recipes key={i} {...recipe}  />

export default Navs;

Thanks for any solution.

Have 1 answer(s) found.
  • N

    Nguyen Truong Giang Jan 24 2021

    Oh, you need to import React library into the head of your component:

    import React, { Component }  from 'react';
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close