React.NET icon indicating copy to clipboard operation
React.NET copied to clipboard

'ReactDOM' is not defined no-undef problem occurs while running this script?

Open naveen2103 opened this issue 4 years ago • 7 comments

Screenshot 2021-03-18 at 6 08 08 PM

code i used :

import ReactDOM from 'react-dom'; import React from 'react';

const App= () =>(

Hello first React project

) ReactDOM.render(<App/>,document.getElementById('root'))

error i got : Failed to compile.

src/index.js Line 14:1: 'ReactDOM' is not defined no-undef

Search for the keywords to learn more about each error.

naveen2103 avatar Mar 18 '21 12:03 naveen2103

can any one help me to solve this problem and say why it occurs because i beginner to this reactjs

naveen2103 avatar Mar 18 '21 12:03 naveen2103

You just have have to correct "import ReacrDOM from ...." into "import ReactDOM from react-dom" The letter 'r' has to be replaced by 't' and give you and also, my advise will be to always put "import React from ...." on top

import ReactDOM from 'react-dom';
import React from 'react';

Make sure to close the issue and it would be great to leave me a star on my profile. You can also fork this Todo-list and get a full ReactJS template project. I am a ReactJS developer and will gladly help you if you have further questions or require an advice on this topic. 👍🏾 Eskabore

Eskabore avatar Mar 19 '21 05:03 Eskabore

import React from "react"; import ReactDOM from "react-dom"; import Heading from "./Heading"; import Para from "./Para"; import List from "./List" function App(){ return ( <> <Heading/> <Para/> <List />

</> ); }

export default App;

Nishikanta30 avatar Jul 30 '21 06:07 Nishikanta30

src\index.js Line 4:1: 'ReactDom' is not defined no-undef Line 6:2: 'App' is not defined react/jsx-no-undef

Search for the keywords to learn more about each error.

Nishikanta30 avatar Jul 30 '21 06:07 Nishikanta30

ReactDOM and ReactDom are different words, check your spelling ,it should be ReactDOM. React is case sensitive

bravol avatar Aug 16 '21 18:08 bravol

Thank you for the response, I experienced the same problem then capitalized DOM then everything worked.

ThulaMabota avatar Mar 10 '22 07:03 ThulaMabota

This is my code: import ReactDOM from 'react-dom'; import React from 'react'; import './index.css'; import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render( <> <App /> </> )

and this is the error I'm getting:

[eslint] src\root.js Line 1:21: 'ReactDOM' is not defined no-undef Search for the keywords to learn more about each error. ERROR in [eslint]

I need Help Please!

Bobby-GMS avatar Nov 23 '23 23:11 Bobby-GMS