Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TylerSustare
Last active September 17, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylerSustare/19b73a3a82b0d3f89fdb5aabf2fb6018 to your computer and use it in GitHub Desktop.
Save TylerSustare/19b73a3a82b0d3f89fdb5aabf2fb6018 to your computer and use it in GitHub Desktop.
Neat use of rest operator in React
class SomeClass extends Component {
onChange({ ...rest }) {
this.setState(rest);
};
options = {
// ...
onChangePage: currentPage => this.onChange({ currentPage }),
onChangeRowsPerPage: numberOfRows => this.onChange({ numberOfRows })
};
render() => (<> stuff </>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment