Skip to content

Instantly share code, notes, and snippets.

@cloudchen
Created November 19, 2018 04:25
Show Gist options
  • Save cloudchen/718f76231a910c17786a5f8b2070196c to your computer and use it in GitHub Desktop.
Save cloudchen/718f76231a910c17786a5f8b2070196c to your computer and use it in GitHub Desktop.
Overwrite React .setState()
setState(updatedState) {
super.setState((...rest) => {
const newState = typeof updatedState === 'function' ? updatedState(...rest) : updatedState;
//add something tricky
return newState;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment