Created
January 28, 2021 07:40
-
-
Save decpk/8599fcff2a57b07952184bef88d33fd7 to your computer and use it in GitHub Desktop.
Initial state with ES6 classes, when defined in constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| class App2 extends Component { | |
| constructor( props ) { | |
| super( props ); | |
| this.state = { | |
| message: 'world' | |
| } | |
| } | |
| render() { | |
| return ( | |
| <h1>Hello {this.state.message} in ES6 classes</h1> | |
| ); | |
| } | |
| } | |
| export default App2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment