react-navigation/rfcs

Action to reload a screen maybe

Closed this issue · 5 comments

I came across a use case where someone wanted to reload a screen in their app but couldn't figure out how to do it so they reloaded the app. Right now you can use replace for this in stack, eg: https://snack.expo.io/Skn48EdeQ. We could build in support for this more cleanly if it seems valuable for people

What do you mean by reloading a screen?

Loading a screen as a new/fresh component which causes it to call its lifecycle methods again @satya164

Why would you need support for this in navigation library? You can manage it yourself by extracting your component and rendering with a special key, or call the methods you want to be called again.

Unless it becomes a highly-requested functionality, I don't think that it would need to become a named feature in the react-navigation API. For now, maybe a small note/guide in the docs explaining this potential use case and solutions for it would be most effective if users are to run into this need again.

Closing this since it isn't very react-y to "reload" a component. If someone really really needs it, replace does the job fine, or by extracting the component and rendering with a new key.

With React Navigation 5 replace is available on all navigators, not just stack.