Reputation: 430
Is there any callbacks to rendered components from the Navigator when a view gets on / off screen?
Upvotes: 1
Views: 407
Reputation: 875
In the renderScene()
method, you can pass a prop like isRendered={route.index === 0}
for the first card, isRendered={route.index === 1}
for the second, etc.
And then in the components themselves, you can use componentWillReceiveProps
like:
componentWillReceiveProps(next) {
const { isRendered } = this.props
if (isRendered && !next.isRendered) // going off screen
if (!isRendered && next.isRendered) // coming on screen
}
Upvotes: 2