-1

I am trying to use JSX in a JSON object but I get this error message
'React' must be in scope when using JSX react/react-in-jsx-scope

import {Translate} from 'react-localize-redux';
import Translations from '../translations/dashboard';

export default {
  items: [
    {
      name: <Translate id="movie.title" />,
      url: '/dashboard',
      icon: 'icon-speedometer',
    },
  ]
}

Please, can someone help me out?

Cash Dogg
  • 165
  • 1
  • 2
  • 11
  • 1
    Does this answer your question? ['React' must be in scope when using JSX react/react-in-jsx-scope?](https://stackoverflow.com/questions/42640636/react-must-be-in-scope-when-using-jsx-react-react-in-jsx-scope) – Henry Woody Oct 24 '22 at 21:20

2 Answers2

4

Add import React from 'react'; at the beginning of the file and make sure filename extension is .jsx or .tsx;

zilijonas
  • 3,285
  • 3
  • 26
  • 49
1

You need to import React into your file.
Add import React from 'react'; at the top
Your file should look like this:

import React from 'react';
import {Translate} from 'react-localize-redux';
import Translations from '../translations/dashboard';

export default {
  items: [
    {
      name: <Translate id="movie.title" />,
      url: '/dashboard',
      icon: 'icon-speedometer',
    },
  ]
}

Note: You may decide to change the extension of the file to .jsx or .tsx as suggested by @LiJonas

Kofi Mokome
  • 189
  • 3
  • 12