Created
June 25, 2016 22:46
-
-
Save pl12133/dacbc72f7f834d8c1867e0e3762372eb to your computer and use it in GitHub Desktop.
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
| /* If you have a React event handler and you want to pass it more than just the `event` argument, you can | |
| * do so in the following ways. | |
| */ | |
| // using an inline Wrapper | |
| handleEvent (someData, event) { | |
| // ... | |
| } | |
| <MyComponent onEvent={(event) => this.handleEvent('someData', event)} /> | |
| // using a higher order function | |
| handleEvent (someData) { | |
| return (event) => { | |
| ... | |
| } | |
| } | |
| <MyComponent onEvent={this.handleEvent('someData')} /> | |
| // using partial application (lodash.partial) | |
| handleEvent (someData, event) { | |
| // ... | |
| } | |
| <MyComponent onEvent={_.partial(this.handleEvent, 'someData')} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment