React-native-router-flux: ActionConst.REPLACE breaks

Created on 17 Jan 2018  ·  13Comments  ·  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux 4.0.0-beta.27
  • react-native v0.52.0

Expected behaviour

Not to break

Actual behaviour

Break

" TypeError: Cannot read property 'map' of undefined"

Steps to reproduce

js <Overlay> <Stack hideNavBar> //... <Modal hideNavBar key={"key1"} initial type={ActionConst.REPLACE} > <Drawer key='root' contentComponent={MenuScreen} initial> <Scene key={"key2"} component={AScreen} type={ActionConst.REPLACE} initial /> <Scene key={"key3"} component={BScreen} type={ActionConst.REPLACE} /> </Drawer>

Most helpful comment

4.0.0-beta.27 works for me!

All 13 comments

Same

Solve it by downgrading to 4.0.0-beta.20

4.0.0-beta.27 works for me!

We started running into this too on the latest version using Actions.reset('someScene').

The full error that I get is:

TypeError: Cannot read property 'map' of undefined
    at Object.getStateForAction (StackRouter.js:263)
    at reducer (Reducer.js:74)
    at NavigationStore.nextState (navigationStore.js:550)
    at NavigationStore.dispatch (navigationStore.js:553)
    at NavigationStore.replace (navigationStore.js:675)
    at AuthActions.js:185
    at tryCallOne (core.js:37)
    at core.js:123
    at JSTimers.js:301
    at _callTimer (JSTimers.js:154)

Same react-native-router-flux 4.0.0-beta.28 had this problem

In the meantime I've rolled back to beta25 and it appears to be working. It looks like react-navigation was upped from beta.21 to beta.22 in this version which could have caused the regression. That is the earliest version back where I saw a change that might be having an effect and the stack trace shows the error as coming from react-navigation. That is my hunch to what the cause is at least, I haven't investigated too much.

This is a known issue #2799

I'm closing this but if you want to use 0.28, do as what @sharkrice said, otherwise, if you don't need the features from 0.28, I suggest you to downgrade to a stable version (like 0.24 in my case) until it's fixed.

4.0.0-beta.27 works for me!

got issue for 4.0.0-beta.28, downgrade to 4.0.0-beta.27 works for me!

got issue for 4.0.0-beta.24 with node v7.10.0, upgrade to 4.0.0-beta.27 works for me.
upgrade node to v8.9.4 with 4.0.0-beta.24 also worked.

@LiuTing0403 我用0.22到0.28都试了一遍 仍然存在这个问题 是不是和RN的版本有关呢 我的是0.52.2

Got the same issue. Downgrade to 4.0.0-beta.27 "fixed" it.

Hi, in 4.0.6 the REPLACE does not work as expected, no errors but the route is not replaced properly.

Any news on this?

I think that this code is also problematic here:
const routes = [...parent.routes.slice(0, index - 1), ...parent.routes.slice(index)];

Shouldn't it be this?
const routes = [...parent.routes.slice(0, index), ...parent.routes.slice(index + 1)];

Was this page helpful?
0 / 5 - 0 ratings

Related issues

willmcclellan picture willmcclellan  ·  3Comments

wootwoot1234 picture wootwoot1234  ·  3Comments

vinayr picture vinayr  ·  3Comments

GCour picture GCour  ·  3Comments

kirankalyan5 picture kirankalyan5  ·  3Comments