Last active
November 14, 2021 17:24
-
-
Save leohxj/d728de1b2df787c69830c56f9bd8f938 to your computer and use it in GitHub Desktop.
[react initialState] initState #react
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 A extends React.PureComponent { | |
state = this.getInitialState(); | |
getInitialState() { | |
const { className } = this.props; | |
return { | |
className | |
}; | |
} | |
onChange = () => {}; | |
resetState() { | |
this.setState(this.getInitialState()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment