React Navigation: addListener('didFocus') called over and over

318 Views Asked by At

I'm using [email protected] in my React Native app, and I want to trigger a function whenever the user switches tabs in my tab navigator. I tried this:

componentDidMount() {
    this.props.navigation.addListener('didFocus', () => {
        <call function>
    })
}

The problem is this now gets called rapidly over and over, and never stops.

Is there a better way to approach this problem?

0

There are 0 best solutions below