What I\'m trying to do:
I am trying to pass a string from a child component to the handleChange function of a parent component.
What cur
In order to pass a param from the child component to the parent you can take an argument to the arrow function.
handleChange(event, section) {
console.log(section);
console.log(event.target.value);
}
this.handleChange(e, val)} />
Sample snippet
class App extends React.Component {
handleChange(e, val) {
console.log(e.target.value, val);
}
render() {
return(
this.handleChange(e, val)}/>
)
}
}
class Child extends React.Component {
render() {
return(
this.props.handleChange(e, 'tab')}/>
)
}
}
ReactDOM.render( , document.getElementById('app'));