My target is to transfer a state boolean value to parent component, which can use for hiding and showing another child components. Example: I have three components. ListViewComponent, ErrorMessageComponent and ParentComponent(which binds first two). In ListViewComponent there is a boolean which is true only if backend data length is zero. I want to send that boolean in parent component and show or hide ErrorMessageComponent according to that boolean.
ListViewComponent:
validateData(newProps){
this.props.onDataLengthZero(newProps.data.length == 0);
}
ParentComponent:
render() {
return (
<View>
<ListViewComponent />
<ErrorMessageComponent errorText="My error message Text" />
</View>
);
}
How can I consume onDataLengthZero
in parent component and hide ErrorMessageComponent
if it is true?