Skip to content

Instantly share code, notes, and snippets.

@decpk
Created January 28, 2021 07:43
Show Gist options
  • Select an option

  • Save decpk/02955e65991eb7ed3f974b660feef995 to your computer and use it in GitHub Desktop.

Select an option

Save decpk/02955e65991eb7ed3f974b660feef995 to your computer and use it in GitHub Desktop.
Initialize state in ES6 classes outside of constructor
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