Hey there, I'm facing a bit of a dilemma with this problem. The issue is that I can't use state within navigationOptions. Here's what I've attempted:
I initialized my variable
let isFilterVisible: boolean = false;
In the navigationOptions block, I'm calling a function in the onPress event.
static navigationOptions = ({ navigation }: NavigationInjectedProps) => ({
headerRight: (
<FilterButton onPress={() => {Installations.handleFilterVisibility(isfilterVisibile)}}/>
),
});
A simple static
function where I manipulate the value
static handleFilterVisibility(filterVisibility: boolean){
isfilterVisibile = !filterVisibility;
}
Then it's passed down to the child component as props
<Filter isFilterVisible={isfilterVisibile}/>
Everything appears to be set up correctly, but when I try to log the props in the child component.
ComponentDidUpdate
and ComponentWillReceiveProps
do not display any logs.
Any thoughts on where I might have gone wrong?