react-native-router-flux: 'ActionConst.Reset' not working properly after few uses

Version

Tell us which versions you are using:

  • react-native-router-flux v3.35.0
  • react-native v0.30.0

Expected behaviour

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.

Actual behaviour

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.

Steps to reproduce

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 :

  • Push calls from A11 to B
  • Then push call from B to C
  • Reset call from C to A (which is the default here).

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…

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 15
  • Comments: 25

Commits related to this issue

Most upvoted comments

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 .

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.

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?