Skip to content

Instantly share code, notes, and snippets.

@KevinVR
Created February 26, 2021 10:40
Show Gist options
  • Save KevinVR/20061b4a9bcbf5dc6aa7df762e8b5b48 to your computer and use it in GitHub Desktop.
Save KevinVR/20061b4a9bcbf5dc6aa7df762e8b5b48 to your computer and use it in GitHub Desktop.
// Class-based component state example
import React from 'react';
class MyComponent extends React.Component {
constructor(props) {
super(props);
// Set the state
this.state = {
myValue = 'test'
};
}
render() {
// Show the value when rendering the component
return <h1>{this.state.myValue}</h1>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment