Last active
September 17, 2019 16:10
-
-
Save TylerSustare/19b73a3a82b0d3f89fdb5aabf2fb6018 to your computer and use it in GitHub Desktop.
Neat use of rest operator in React
This file contains hidden or 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 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