and thanks for any assistance.
I have a parent-child component setup where the state of the parent is passed down as props to the child, also one of the props is an onClick event handler who's button lives in the child but handled in the parent. When the onclick is pressed it is going to raise that handle event in the parent, where the parent will call up to the api to get some data. When this is complete, the child needs to be notified.
My question is: Other than including another prop that the parent would set - which would let the child know the parent is complete, what are my options? (note: i am not using Redux and was hoping not to).
Could Promises work here (See code below) or is props the recommended implementation. (My concern with props is that I am already passing 6 or so to the child and I didn't want to keep adding more especially for something like this)
Parent:
private handleOnclick = () => {
this.apiService.getData() ...
}
<Child onClick={this.handleOnclick} ...
Child:
Child has an internal handleButtonOnclick function that calls to the parent.
private handleButtonOnclick = () => {
this.props.handleOnclick().then( () => {
**WHEN COMPLETE TAKE SOME ACTION.**
});
}
<Button onClick={() => this.handleOnclick()} >Click Me</Button>
As you can see, I am trying to figure out how to notify the client back after the parent has finished processing (without using props or some state management lib)
thanks!