7. The Render Function (Por favor, no sean malos!)


#1


Help me please=

Select new.js.

Make some new lines in between var ReactDOM = require('react-dom'); and var MyComponentClass ....
In this new space, declare a new variable named componentBlueprint. Set componentBlueprint's value equal to an empty object literal.

¡Qué tengo malo!.. Aiudaaaaaaaa :slight_smile:


var React = require('react');
var ReactDOM = require('react-dom');

var componentBlueprint = {};

var MyComponentClass = React.createClass({
  render: function () {
    return <h1>Hello world</h1>;
  }
});

ReactDOM.render(
	<MyComponentClass />, 
	document.getElementById('app')
);


#2

When we enter the new.js tab, the component class looks like this:

var MyComponentClass = React.createClass();

do not write anything into the class (until the last step). The above render property will get written into the componentBlueprint object:

var componentBlueprint = {
  render: function () {
    return <h1>Hello world</h1>;
  }
}

Finally, we pass this to the component class:

var MyComponentClass = React.createClass(componentBlueprint);

#3

Thanks friend :blush:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.