Skip to content

Instantly share code, notes, and snippets.

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

  • Save decpk/8599fcff2a57b07952184bef88d33fd7 to your computer and use it in GitHub Desktop.

Select an option

Save decpk/8599fcff2a57b07952184bef88d33fd7 to your computer and use it in GitHub Desktop.
Initial state with ES6 classes, when defined in constructor
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