简体   繁体   中英

ReactDom is declared but its value is never read

I am just starting to learn react and I am trying this code:

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

const element = <h1>Hello world</h1>;
console.log(element);

But I have error:

ReactDom is declared but its value is never read 在此处输入图像描述 what may cause this error please?

On line two you declare ReactDom (and assign (ie write ) the imported value from the react-dom module to it).

 import ReactDom from 'react-dom';

… and then you never do anything with it (ie you don't read the value back out of the ReactDom variable).

Normally in a React application you would use ReactDom to insert a component into the DOM, but here you just console.log the result of evaluating some JSX instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM