Answer the question
In order to leave comments, you need to log in
How to do it right in React?
Hello!!
class Test extends React.Component
{
construcrot(props)
{
super(props);
this.handleClick = (value) => this.handleClick.bind(this, value)
}
handleClick(object) {
}
render() {
const objectTest = {
id: 1,
name: 'Test-1'
}
};
}
return (
<div>
<input type="button" onClick={this.handleClick(objectTest)}>
</div>
);
}
}
Answer the question
In order to leave comments, you need to log in
So:
return (
<input type="button" onClick={ this.handleClick.bind(this, objectTest) } />
);
This should be enough.this.handleClick = this.handleClick.bind(this)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question