Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor

A React component can access dynamic information in two ways: props and state.

Unlike props, a component's state is not passed in from the outside. A component decides its own state.

To make a component have state, write a getInitialState function:

var Example = React.createClass({ getInitialState: function () { return { mood: 'decent' }; }, render: function () { return <div></div>; } }); <Example />

getInitialState should return an object, like in the example above.

Look at the bottom of the above code. <Example /> has a state of { mood: 'decent' }.

Report a Bug
If you see a bug or any other issue with this page, please report it here.