I am following this tutorial on react and i am getting the reactDOM is not defined:
import React from 'react';
import { render as renderJSX } from 'react-dom';
// The two components we're to passing props to
// when they're rendered.
import MyButton from './myButton';
import MyClientList from './myClientList';
const appState = {
text: 'My Button',
disabled: true,
items: [
'First',
'Second',
'Third', ],
};
// Defines our own "render()" function. The "renderJSX()"
// function is from "react-dom" and does the actual
// rendering. The reason we're creating our own "render()"
// function is that it contains the JSX that we want to
// render, and so we can call it whenever there's new
// application data.
function render(props) {
renderJSX((
<main>
{ /* The "MyButton" component relies on the "text"
and the "disabed" property. The "text" property
is a string while the "disabled" property is a
boolean. */ }
<MyButton
text={props.text}
disabled={props.disabled}
/>
{ /* The "MyList" component relies on the "items"
property, which is an array. Any valid
JavaScript data can be passed as a property. */ }
<MyClientList items={props.items} />
</main>
),
document.getElementById('app')
);
// Performs the initial rendering...
render(appState);
// After 1 second, changes some application data, then
// calls "render()" to re-render the entire structure.
setTimeout(() => {
appState.disabled = false;
appState.items.push('Fourth');
render(appState);
}, 1000);
I have seen other post but I can still not get it to work. I am starting out in react and I would like to understand why i am getting the below error:
question from:
https://stackoverflow.com/questions/65623169/react-js-reactdom-is-not-defined-no-undef 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…