Sunday, July 16, 2017

13/07/2017

React State 

State is the place where the data comes from.If we have, for example, ten components that need data from the state, we should create one container component that will keep the state for all of them.

App.jsx

import React from 'react';

class App extends React.Component {
   constructor(props) {
      super(props);
  
      this.state = {
         header: "Header from state...",
         content: "Content from state..."
      }
   }
 
   render() {
      return (
         <div>
            <h1>{this.state.header}</h1>
            <h2>{this.state.content}</h2>
         </div>
      );
   }
}

export default App;

No comments:

Post a Comment

HTML introduction

HTML stands for Hyper Text Markup Language. HTML describes the structure of web page using markup. HTML elements are the building blo...