Skip to content

Instantly share code, notes, and snippets.

@leohxj
Last active November 14, 2021 17:24
Show Gist options
  • Save leohxj/d728de1b2df787c69830c56f9bd8f938 to your computer and use it in GitHub Desktop.
Save leohxj/d728de1b2df787c69830c56f9bd8f938 to your computer and use it in GitHub Desktop.
[react initialState] initState #react
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