JSX converter using React.createElement ("h1", null) instead of React.DOM.h1 (null)

JSX transformer causes errors

When I convert my response files using a converter from responsive tools

$ jsx public/dev/jsx public/prod/js --no-cache-dir 

Or when I convert with grunt-react

  $ grunt react 

My production file is broken because the conversion uses React.createElement and the error says that this function is undefined.

  <h1>{this.state.title}</h1> 

converted to:

  React.createElement("div", null, React.createElement("h1", null, this.state.title) 

instead:

  React.DOM.h1(null, this.state.title) 

The live converter works fine because it uses React.DOM.h1(null, this.state.title) . This line of code works well with the reaction, but the React.createElement() function does not work and is not found.

How can I make my automatic converter, JSX or grunt, convert to React.DOM.h1(null) instead of React.createElement(h1, null) . Why does the converter use this feature?

+6
source share
2 answers

I had the same error with lib coffee response. These libraries are updated for React 0.12. If you're still on React 0.11, you will probably need to drop grunt-responsive to a slightly older version or lash out at React 0.12.

+4
source

Yes, I really upgraded to React 0.12, and it started working ... Thanks.

0
source

Source: https://habr.com/ru/post/977519/


All Articles