Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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