React.DOM Fails with undefined

Asked 2 years ago, Updated 2 years ago, 52 views

I want to learn the basics, so I want to move without JSX first, and when I use React.DOM.div, I get the following error:

build.js:20123 Uncaught TypeError: Cannot read property 'div' of undefined

const React=require('react');
// approximately

const HelloWorld=createReactClass({
  render: function() {
    return React.DOM.div({},
      'Hello World'+
      this.props.name);
  }
});
// approximately

"dependencies": {
  "create-react-class": "^15.6.3",
  "react": "^16.3.0",
  "react-dom": "^16.3.0"
}

You can run React alone and React+JSX on a directly specified CDN of the HTML script tag.
This is my own technique page.

How to write JSX understand in React.js HelloWorld (beginning) - Qiita

Thank you for your cooperation.

javascript reactjs

2022-09-30 17:16

1 Answers

React.DOM was announced to be decommissioned in React 15.x and was actually decommissioned in 16.0.

If you want to continue using the same API, the package react-dom-factories is available.
Currently, the official documentation introduces the use of React.createElement.


2022-09-30 17:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.