You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the API looks reasonable, and we have actually experimented with something similar. We're working on some big changes to Navigator to get the route stack logic out, and to upgrade to the new Animated API. This should be pretty easy to add when we make those changes
Animated replace would've been awesome! I often find it useful to replace main view controller when using e.g. side menu. Unfortunately, I am quite limited currently, so waiting for the updates in this matter
@miracle2k Although that allows replace to use the animations from push, I don't think it behaves the same. replace() will unmount the current component and then mount the new one immediately.
@miracle2k@fender I found this problem too, the view i want to replace was a view which using camera, and using this way the camera page cannot be unmounted and it is keep using the camera, which makes my App deny by App Store because of something like "using camera background". I am now using setTimeout to push new view back after poping current view.
I have tried all of these solutions above but all didn't work.
So I had to check the Navigator source code while coded on my own. Finally after solving some problems such as flashing and animating, not working at all, replacing without animation though I have written the code, I got the solution.
These are my code below. Most of them are copied from Navigator source code. What I did is just combine them in a right way. Um...of course, they still can be optimized. And they too much hard to understand. Trust me, I won't understand after tonight. But it works. It's enough.
BTW, my RN is 0.27.
After defining that in prototype, you can use it anywhere you want.
Just like navigator.replaceWithAnimation(route);
Reacted by Himanshu Satija, Edgar Nunes, VinceBT, Ben McMahen, Waleed Arshad, Terry Zhao, Jian LI, Fabricio Vergara, Sebastian Germesin, yankai and 6 more
Reacted by Jian LI, Lou George, Terry Zhao, Ilyaololo, ViNZ and Fareed Alnamrouti
@waleedarshad-vf I used it in online production and after compiling them by react native and set to production mode. It's quite fluent. Have you tried the production mode?
@zhaotai thanks for you reply. I tried it again last day and it is working now. i don't know what happened that time. it might be due to low memory of the device.
@waleedarshad-vf Yeah, especially you develop in the simulator. The application memory will increase along with your code complication increasing and as a result the navigating and animation which is implemented by js code instead of native module will become slow and unsmooth.
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless
Product Pains has been very useful in highlighting the top bugs and feature requests: https://productpains.com/product/react-native?tab=top
Also, if this issue is a bug, please consider sending a pull request with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
Activity
jeanregisser commentedon Jul 13, 2015
Was thinking about the same.
If we can agree on an API I would gladly submit a PR implementing it.
sahrens commentedon Jul 15, 2015
What do you think, Eric?
ericvicenti commentedon Jul 15, 2015
I think the API looks reasonable, and we have actually experimented with something similar. We're working on some big changes to Navigator to get the route stack logic out, and to upgrade to the new Animated API. This should be pretty easy to add when we make those changes
grabbou commentedon Jul 17, 2015
Animated replace would've been awesome! I often find it useful to
replacemain view controller when using e.g. side menu. Unfortunately, I am quite limited currently, so waiting for the updates in this mattermiracle2k commentedon Sep 8, 2015
I'm doing something like this now to skip a payment screen route that I really don't want in the stack:
It works, but I'd really rather not have this screen have the responsibility to know about the previous routes.
grabbou commentedon Sep 9, 2015
@miracle2k for this specific use case, take a look at our implementation https://github.com/este/native/blob/master/src/app/app.react.js#L105-L108. We are decorating Navigator with few handy methods and passing it down, this particular one works quite well.
ericvicenti commentedon Oct 6, 2015
For now maybe you could do a push and then
immediatelyResetRouteStackonce the transition completeschirag04 commentedon Oct 6, 2015
@ericvicenti cool. so
immediatelyResetRouteStackindidfocusshould do the trick?miracle2k commentedon Oct 10, 2015
Inspired by the suggestion from @grabbou, I am now using this workaround:
Note the overwrites of
replace()andpop(). pop will skip all routes that have been replaced.fender commentedon Dec 2, 2015
@miracle2k Although that allows
replaceto use the animations frompush, I don't think it behaves the same.replace()will unmount the current component and then mount the new one immediately.DickyT commentedon Jan 20, 2016
@miracle2k @fender I found this problem too, the view i want to replace was a view which using camera, and using this way the camera page cannot be unmounted and it is keep using the camera, which makes my App deny by App Store because of something like "using camera background". I am now using setTimeout to push new view back after poping current view.
Hope next official release can fix this.
ssh-randy commentedon Feb 4, 2016
I still find this problem as well, when I have sceneconfig set, it does not work for type replace even though it does for pop
aksonov commentedon Feb 4, 2016
Any ETA on this, @ericvicenti ?
aksonov commentedon Feb 4, 2016
Looks like following code works well, could it be used as workaround?
4 remaining items
vaukalak commentedon May 27, 2016
For now I use this workaround:
https://gist.github.com/vaukalak/40ed12eadf0f605a8ffc4584144f2fdd
then in my code I do:
not too elegant, but seems to work :)
zhaotai commentedon Jun 3, 2016
I have tried all of these solutions above but all didn't work.
So I had to check the Navigator source code while coded on my own. Finally after solving some problems such as flashing and animating, not working at all, replacing without animation though I have written the code, I got the solution.
These are my code below. Most of them are copied from Navigator source code. What I did is just combine them in a right way. Um...of course, they still can be optimized. And they too much hard to understand. Trust me, I won't understand after tonight. But it works. It's enough.
BTW, my RN is 0.27.
After defining that in prototype, you can use it anywhere you want.
Just like
navigator.replaceWithAnimation(route);waleedarshad-vf commentedon Jun 25, 2016
Performace is too slow above provide method, can anyone optimized it
zhaotai commentedon Jun 28, 2016
@waleedarshad-vf I used it in online production and after compiling them by react native and set to production mode. It's quite fluent. Have you tried the production mode?
waleedarshad-vf commentedon Jun 28, 2016
@zhaotai thanks for you reply. I tried it again last day and it is working now. i don't know what happened that time. it might be due to low memory of the device.
zhaotai commentedon Jun 29, 2016
@waleedarshad-vf Yeah, especially you develop in the simulator. The application memory will increase along with your code complication increasing and as a result the navigating and animation which is implemented by js code instead of native module will become slow and unsmooth.
waleedarshad-vf commentedon Jul 1, 2016
@zhaotai one thing to be mention here that it is not as smooth as the push method of Navigator but thanks for Awesome work
waleedarshad-vf commentedon Jul 13, 2016
@zhaotai it needs attention to make it as smooth as push method. the tester here points out this jerk animation issue in a single attempt.
zhaotai commentedon Jul 18, 2016
@waleedarshad-vf I will try, thanks for suggestion. Maybe you can improve it, too.
mkonicek commentedon Oct 27, 2016
Hi there! This issue is being closed because it has been inactive for a while.
But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/navigator-animated-replace
ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub. GitHub issues have voting too, nevertheless
Product Pains has been very useful in highlighting the top bugs and feature requests:
https://productpains.com/product/react-native?tab=top
Also, if this issue is a bug, please consider sending a pull request with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.
Add Replace With Animation feature to Navigator