React-native-router-flux: Problem about pop and refresh

Created on 16 Nov 2016  路  15Comments  路  Source: aksonov/react-native-router-flux

#

  • react-native-router-flux v3.36.0
  • react-native v0.34.1

Expected behaviour

I have the situation like that. I'm in scene A and push to scene B. I want to change something in scene B and pop to scene A and scene A should be update some data (not all). I used:

Actions.pop()
setTimeout(()=> {
Actions.refresh({test:true});
}, 10)

but it was not working well. Actually scene A is a tab scene, there are 4 tabs in there and all data in there should be update. Could you please to show me how to resolve this situation with react-native-router-flux. Thank you!

Most helpful comment

Hello guys, I have the same problem with tab scene too : componentWillReceiveProps is not triggered using Actions.pop({refresh: {...}}).

All 15 comments

You should use this:

Actions.pop({ refresh: { test: true }})

This will POP the current view off the stack and refresh the previous with the props being passed.

Where is this documented?

@ddolheguy This did not work for me. I used Actions.pop({refresh: {test:true}}). Previous scene was shown but none of the react component lifecycle methods of the component were called.

@iWebi when you call Actions.pop({refresh: {test:true}}) componentWillReceiveProps is called on the previous scene

@juancabraal while this is a solution for some, this isn't practical for all cases. Where someone is fetching and rendering a list of data with help from componentWillReceiveProps, trying to put Actions.refresh() inside this method will call an infinite componentWillReceiveProps.

I have the same problem. I use tab scene.

Hello guys, I have the same problem with tab scene too : componentWillReceiveProps is not triggered using Actions.pop({refresh: {...}}).

I have the same problem with tab scene too :(

same here:
onBack={ () => Actions.pop({ refresh: { test: true } }) }

Doesn't trigger a refresh of the component

react-native v0.43.1
react-native-router-flux v3.38.0

 I resolve               Actions.pop({refresh: {test:Math.random()

you must put difference data ,it will work

@truckhiem
I also faced an similar issue.
You can write a componentWillUnmount() in scene B, and call the methods that are required to update scene A. This worked for me.

The only solution for this is to call the sceneA Actions.sceneA() 馃

that's not ideal as i have to keep track of what page to go back too, which could be several.

I found the only working solution to trigger componentWillReceiveProps on the previous scene here:
https://github.com/aksonov/react-native-router-flux/issues/2047#issuecomment-315976469
Actions.pop();
setTimeout(() => { Actions.refresh({ someProp: someValue }); }, 0);

I am locking this issue to focus on bugs and issues in the v4.

v3 and v4-beta are not supported anymore - in case you found a bug or would like to improve something, PRs are welcome, but I recommend to update to the most recent version to make use of last version of react, react-navigation and react-native.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moaxaca picture moaxaca  路  3Comments

sarovin picture sarovin  路  3Comments

sreejithr picture sreejithr  路  3Comments

GCour picture GCour  路  3Comments

tonypeng picture tonypeng  路  3Comments