Created
January 28, 2021 07:43
-
-
Save decpk/02955e65991eb7ed3f974b660feef995 to your computer and use it in GitHub Desktop.
Initialize state in ES6 classes outside of 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 { | |
| state = { | |
| message: 'world' | |
| } | |
| render() { | |
| return ( | |
| <h1>Hello {this.state.message} in ES6 classes outside of constuctor</h1> | |
| ); | |
| } | |
| } | |
| export default App2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment