منگل، 16 اگست، 2016

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. App.jsx importReactfrom'react';classAppextendsReact.Component{ constructor(props){super(props);this.state ={ header:"Header from state...","content":"Content from state..."}} render(){return(

{this.state.header}

{this.state.content}

);}}exportdefaultApp; main.js importReactfrom'react';importReactDOMfrom'react-dom';importAppfrom'./App.jsx';ReactDOM.render(, document.getElementById('app'))


کوئی تبصرے نہیں:

ایک تبصرہ شائع کریں