-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorate class method passed to child component #109
Comments
You should be able to just decorate The signature when decorating (synchronous) class methods is: @track((props, state, args) => {}) Returning an object will dispatch a tracking event. For example (using the arg passed into @track() // this is necessary so decorating class method works
class Wrapper extends Component {
state: {
tabIndex: 0,
buttons: [1,2,3],
}
@track((props, state, [index]) => ({ event: 'tab-switch', index }))
switchTab(index) {
this.setState({ tabIndex: index })
}
render() {
return <Tabs clickHandler={this.swtichTab.bind(this)} } />
}
} |
@tizmagik thanks for your clear answer :) |
Thanks @cpprookie -- yes a PR would be greatly appreciated. I plan on creating some kind of "common patterns" doc for more detailed examples, as you suggested, so you can link your PR to this issue: #86 Cheers! |
Ok. I will do some work on this weekend. |
Thanks for your wonderful plugin.
After reading readMe, I wonder how to decorate class methods passed to childComponent as event handler with params.
For example. I get class component Wrapper
And it contains several buttons
Is there a way to track index param for decorated switchTab param?
The text was updated successfully, but these errors were encountered: