Skip to content

Instantly share code, notes, and snippets.

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

  • Save decpk/1cc693db112f0185c599faa894090ca4 to your computer and use it in GitHub Desktop.

Select an option

Save decpk/1cc693db112f0185c599faa894090ca4 to your computer and use it in GitHub Desktop.
Initial state in React Before ES6
const React = require( 'react' );
const CreateReactClass = require( 'create-react-class' );
const App = CreateReactClass( {
getInitialState() {
return {
message: 'world'
}
},
render() {
return React.createElement( 'h1', null, `Hello ${this.state.message}` );
}
} )
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment