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