Call Child Function From Parent In React 16
After upgrading to react 16 I am getting null in console.log(this.child) My parent component import EditReview from './partials/editReview' class VenueDetails extends Component {
Solution 1:
You have to assign the ref:
<EditReview {...this.props} ref={this.child} />
Also, you don't need to use inline arrow function:
onClick={() => this.editButtonClick(review, i)}
// ------^^^^^ not required
// because, you're already using public class method
Just use:
onClick={this.editButtonClick(review, i)}
Define your method like this:
editButtonClick = (review, index) => { // to access review, i
Post a Comment for "Call Child Function From Parent In React 16"