W
W
WEBIVAN2016-03-09 16:50:46
React
WEBIVAN, 2016-03-09 16:50:46

Is it possible to call ReactDOM.render() from JS when using JSX?

I am studying React and the question arose:
As I understand it, the code written with JSX does not overlap in scope with regular JS. So the question is, if I want to get the data in "regular" JS and then call ReactDOM.render() after getting it, how is it possible to do that?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dark_Scorpion, 2016-03-09
@Dark_Scorpion

JSX is transformed into regular js.

var Nav, Profile;
// Input (JSX):
var app = <Nav color="blue"><Profile>click</Profile></Nav>;
// Output (JS):
var app = React.createElement(
  Nav,
  {color:"blue"},
  React.createElement(Profile, null, "click")
);

It is correct to pass data to ReactDOM.render( ), only as parameters.

W
WEBIVAN, 2016-03-09
@WEBIVAN

Thanks everyone.
I realized that the main mistake was in translating JSX to JS through babel and not through the IDE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question