React-native-navigation: [v2] Error in pushing component

Created on 7 May 2018  ·  7Comments  ·  Source: wix/react-native-navigation

Issue Description

I am quite sure I haven't made any changes to my code, but a recent npm install, with all versions remaining same, Navigation.push is throwing a warning:

push should be called from a stack child component

I am not even sure what this means! Here's the layout I am using right now:

```js
LoginStack: {
stack: {
children: [{
component: {
name: 'Login'
}
}]
}
}


And this is what I am using to push:

```js
Navigation.push(this.props.componentId, {
  component: {
    name: 'OTP',
    passProps: {phone: this.state.phone}
  }
})

Steps to Reproduce / Code Snippets / Screenshots

img_681c89cb4aa6-1


Environment

  • React Native Navigation version: 2.0.2274
  • React Native version: 0.55.3
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Device
iOS acceptebug v2

Most helpful comment

Im getting the same error

Navigation.setRoot({
      root: {
        stack: {
          id: 'MyStack',
          children: [
            {
              component: {
                name: 'SIGNUP',
              },
            },
            {
              component: {
                name: 'LOGIN',
              },
            },
          ],
        },
      },
    })

Then after async action executing

Navigation.push('MyStack', {
      component: {
        name: 'SIGNUP',
      },
    })

All 7 comments

You're calling Navigation.push with a componentId which is not in a stack. You can assign a predefined ID to the stack and use it instead of this.props.componentId from props.

@guyca That does not seem possible, as the line I am getting this error from is in the "Login" component, which as you can see in the Layout above, is a child in the stack!

@heroic Can you please PR a failing e2e test to the v2 branch? If you're not comfortable writing a Detox test, just PR the problematic layout to the playground app so I can look into this issue.

Im getting the same error

Navigation.setRoot({
      root: {
        stack: {
          id: 'MyStack',
          children: [
            {
              component: {
                name: 'SIGNUP',
              },
            },
            {
              component: {
                name: 'LOGIN',
              },
            },
          ],
        },
      },
    })

Then after async action executing

Navigation.push('MyStack', {
      component: {
        name: 'SIGNUP',
      },
    })

@ramonallday If you believe this is a bug in RNN, Please PR a failing e2e test.

@guyca https://github.com/wix/react-native-navigation/pull/3310 I hope this makes sense what I am trying to accomplish

Was this page helpful?
0 / 5 - 0 ratings