react-navigation / rfcs

RFCs for changes to React Navigation
Other
88 stars 16 forks source link

Action to reload a screen maybe #47

Closed brentvatne closed 4 years ago

brentvatne commented 6 years ago

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

satya164 commented 6 years ago

What do you mean by reloading a screen?

FiberJW commented 6 years ago

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

satya164 commented 6 years ago

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.

FiberJW commented 6 years ago

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.

satya164 commented 4 years ago

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.