ReactJS - State


State is the place where the data comes from. You should always try to make your state as simple as possible and minimize number of stateful components. If you have, for example, ten components that need data from the state, you should create one container component that will keep the state for all of them.

Using Props

Code sample below shows how to create stateful component using EcmaScript2016 syntax.


import React from 'react';

class App extends React.Component {
   constructor(props) {
      this.state = {
         header: "Header from state...",
         "content": "Content from state..."
   render() {
      return (

export default App;


import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.jsx';

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

This will produce following result:

React State Simple