Created
February 26, 2021 10:40
-
-
Save KevinVR/20061b4a9bcbf5dc6aa7df762e8b5b48 to your computer and use it in GitHub Desktop.
This file contains 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
// 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