Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Actions.key() not reload the components Scene #3225

Closed
pierol opened this issue Aug 28, 2018 · 11 comments
Closed

Calling Actions.key() not reload the components Scene #3225

pierol opened this issue Aug 28, 2018 · 11 comments

Comments

@pierol
Copy link

pierol commented Aug 28, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.1 (v3 is not supported)
  • react-native v0.55.4

Expected behaviour

Refresh of the components of Scene when it is called with:

Actions.key();

Actual behaviour

I update from react-native-router-flux 4.0.0.beta27 where the default behaviour was that when i called Actions.key() the components of the Scene were reloaded, but now it doesn't happen.
Probably i miss something new, some parameter ?

@daviscabral
Copy link
Collaborator

Do you have a sample code? I have no idea about what might be happening here.

@pierol
Copy link
Author

pierol commented Aug 28, 2018

I made an example code to show you what i mean go here: https://github.com/pierol/rnrf-example it's an EXPO example try to open it in a ios simulator. Make login inside the app with these credentials: pierol and pw: giulia09. You have to swtch the version of react-native-router-flux from 4.0.0.beta.27 and 4.0.1 to see the two different behaviours. There is a console log in the DayList componenetWillMount method this component is part of the first Scene. After the Login is successfully i will make an Actions.choorHour() call to return to the first Scene, the one with the Daylist component. Only using 4.0.0.beta.27 will reload the component DayList when i return to the main scene from the Login form.

@daviscabral
Copy link
Collaborator

Thank you for providing the example - I'll investigate further later tonight.

@daviscabral
Copy link
Collaborator

The main point to be aware here is that RNRF had a major library upgrade (react-navigation) during the v4.0.0-beta.x releases. So beta.31was the last version using [email protected]. After that RNRF started to use [email protected] that deprecated some stuff, and removed others - but also added lots of new things/fixes.

@pierol
Copy link
Author

pierol commented Aug 29, 2018

In general i think that it's not the right behaviour do not refresh the components of a scene when you focus on it. The component could have in its componentWiilMount a fetch like in the example i made. Another solution could be to set in the an atttribute that specify if refresh or not, but it should refresh as default behaviour.

@daviscabral
Copy link
Collaborator

That would not be a refresh - refreshing automatically a component would make sense if params were going to change - if they do not change, you will not get any reason the trigger render again. If they change, you will need to inform that, in that case, I believe it's more flexible and less problematic to allow users works with it in the ways that might be the best for them. Do you know what I mean?

@pierol
Copy link
Author

pierol commented Aug 29, 2018

Yes i understand what you mean :

I believe it's more flexible and less problematic to allow users works with it in the ways that might be the best for them.

Thats's right it could be a attribute in the Scene tag like :

<Scene .... refreshOnFocus={true} ... />

@daviscabral
Copy link
Collaborator

This might get easier to fix with the proposal work that I am going to do in #3240.

@daviscabral
Copy link
Collaborator

@pierol Now that I got deeper in that code a bit more - I believe you can get done using onEnter={Actions.refresh}. This will trigger a refresh every time the Scene get focused.

Other thing you might try too is to have a call with params: Actions.key(params). Reopen the ticket if those solutions does not work. Also, there is an opened PR that have a few fixes and samples that show this.

@pierol
Copy link
Author

pierol commented Sep 29, 2018

Sorry but with onEnter={Action.refresh} in the example code i made it doesn't work.

@pierol
Copy link
Author

pierol commented Sep 29, 2018

Sorry i didn't update the react-native-router-flux to the version 4.0.4, now it works with onEnter={Actions.refresh}, thank you for the support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants