Tell us which versions you are using:
Considering the following pattern :
Three different scenes : A, B, C.
I go from A to C by pushing each scene meaning : A --push--> B --push--> C.
Now that I am in C I can go again in A using a type: ActionConst.RESET - this is mandatory, I do not want use Actions.popTo or back actions because A is not always the parent of C.
This works fine the first time : A dismount and mount with the new informations and it should do it everytime.
But, when doing :
A --push--> B --push--> C --reset--> A --push--> B --push--> C --reset--> A
The last reset do not work as intended, the A component do not dismount and remount properly.
It does a strange behaviour as if componentWillMount() isn't called the second time.
1.
Store configuration :
<Scene key="B"
component={B}
title="B"/>
<Scene key="C"
component={C}
title="C"/>
<Scene key="A" component="NavigationDrawer" type={ActionConst.RESET} >
<Scene key="Tabs" tabs={true} default="A1">
<Scene key="A1" default='A11'>
<Scene key="A11"
title="A11"
component={A11}
leftButtonImage: require(_someImage_),
leftButtonIconStyle:{_someStyle_}, />
In A11 component :
componentWillMount() {
Actions.refresh({onLeft: () => _someAction_}) ;
}
Sequence :
Replay the sequence for that sweet no remount : the first and second time the onLeft action "_someAction_" will properly work BUT, at the third time (after the second sequence), the button just does nothing, as if it wasn't set by Actions.refresh.
Maybe I'm missing something here, but it isn't the first time I observe this behaviour.
If anyone have a clue of what his happening here...
I'm experiencing the same on RN 0.29.0 and RNRF 3.34.0!
Same in RN 0.31.0 and RNRF 3.35.0, if you have any idea...
Well, at the moment, I just try to do not use 'refresh' at all. Didn't find any other solution yet...
Maybe @aksonov have some advices on how to use this Action.Const ?
@aksonov I have exactly the same problem
Yep I too can confirm this is a bug
I can even reproduce this weird behaviour with simple steps. Two scenes, A --> B, B then resets to A (Action.A({type: "reset"})). This first time scene A is recreated, constructor is called, etc. If you go again to B and try to reset again, A's constructor is not called and the same previous scene is used.
I have the same problem as @guimello too
I am experiencing the same issue described here, reset works only once in my case
How is your router with the scenes setup? If you have a few things like embedded routers, reseting goes awol.
I'm experiencing similar issues.... version 3.37.0
I am also facing this issue, reset will only work once
Let's say, saying you have the same problem resetting is all fine in all. But to get some help to fix this problem. Posting some example code of routers and how you are resetting would provide more scope to be able to give help on.
Yes I said in my previous comment you don't need anything special. To scenes A, B. Scene A go to B. B reset to A. A's constructor is called. Do the same thing again. A's constructor is not called.
Again you don't need anything special.
In the end, In order to fix things by my side I added a nested route wrapping A. Something like:
<Scene key="A" initial={true}>
<Scene key="first" />
</Scene>
<Scene key="B" />
Now constructors are called always as expected.
In your first scene inside of scene 'A' can you add initial={true} and see what is does.
So your scenes from above provided looks like.
<Scene key="A" initial={true}>
<Scene key="first" initial={true}/>
</Scene>
<Scene key="B" />
Wrapping a scene like my example fixed for me as I said earlier. So you don't need to duplicate the initial property. The problem is that I don't think this should be necessary.
The problem happens when you write siblings scenes.
<Scene key="A" initial={true}/>
<Scene key="B" />
Then, B can't reset more than once to A again. Actually it does reset, but only once the A's constructor is actually called. The second time, B is just removed from the hierarchy (pop).
BTW, I'm resetting with Actions.A({type: 'reset'}).
Are you calling the reset from Scene A or Scene first?
If you are calling the reset from scene first. You could try to wrap the inner scenes ie, scene first in a router. I know that this library is not meant to have this type of formatting with embedded routers, but until we can solve this problem, this could be a temporary by pass for now.
<Scene key="A" initial={true}>
<Router key="sceneARouter">
<Scene key="first" initial={true}/>
</Router>
</Scene>
<Scene key="B" />
I see, what I did instead was to reset to another scene (which my business logic allowed) and then later I could safely reset to the initial scene.
Looking at the code I can see that reseting to the to a view which is currently on the stack, just pops the other scenes in front of it. At least this is my understand.
I'd prefer to be actually "reset" the scene being reset, meaning, we should use another instance so the constructor is called again.
So, what is the intended behaviour?
Getting this on RN 0.38.0 RNRF 3.37.0
Hey @guimello. Tried what you said:
<Scene key="discussionsTab" icon={DiscussionsIcon}>
<Scene key="listDiscussions"
initial={true}
component={Discussions}
title="DISCUSSIONS"
>
<Scene key="first" />
</Scene>
<Scene key="createDiscussion"
component={CreateDiscussion}
title="CREATE DISCUSSION"
/>
</Scene>
listDiscussions -> createDiscussion
then Actions.listDiscussions({ type: 'reset' })
however running into the same issue where the reset only works once.
Any advice?
@booboothefool Not really, and I don't see how this would work using this lib. Because your first scene is on the stack, this lib just pops until it. Reset does not apply. Actually I don't know why it only works once.
I did not have time to investigate this further, but this is really a common behaviour.
When I have some time, which sadly will not be soon, I'll create a sample project with this behaviour, and perhaps dig into some code later on.
Any advice on this issue? Reset is working only once.
Any update or workaround on this? I'm having the same issue!
Did anyone have a successful workaround or solution for this?
I would say this is not relevant to v4 as the bare bones on the library has
changed. So sorry bo. This was oblver a year ago. Think before posting in
closed issues. Thanks
On 8 Feb. 2018 7:28 am, "Matt Kennedy" notifications@github.com wrote:
Did anyone have a successful workaround or solution for this?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/aksonov/react-native-router-flux/issues/1110#issuecomment-363864001,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AXs077creilYjHYdUnrjzVOhlBYuxNN2ks5tSes6gaJpZM4JuTVT
.
Most helpful comment
I can even reproduce this weird behaviour with simple steps. Two scenes, A --> B, B then resets to A (
Action.A({type: "reset"})). This first time scene A is recreated, constructor is called, etc. If you go again to B and try to reset again, A's constructor is not called and the same previous scene is used.