question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Native this.props.navigator.push can't push a component twice for Navigator

See original GitHub issue

When I use a function like this:

driverCreateTrip: function(){
    this.props.navigator.push({
      title: "New Trip",
      component: DriverCreateAccount,
    });
  },

, if I have already pushed the DriverCreateAccount component in a previous .js file, then it seems I can’t use the push again, does it mean I have to use pop to get back to where I want to go? I can’t push the same component twice to the stack?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yogurt-island-331commented, Sep 28, 2015

@hedgerwang so it works if I push a component that hasn’t been pushed before, but if I push something already on the stack then it gives me this error

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `Navigator`.reactConsoleError @ ExceptionsManager.js:86warning @ warning.js:42ReactElementValidator.createElement @ ReactElementValidator.js:322React.createClass.renderScene @ index.ios.js:34React.createClass._renderScene @ Navigator.js:1057(anonymous function) @ Navigator.js:1084React.createClass.render @ Navigator.js:1078ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext @ ReactCompositeComponent.js:715ReactCompositeComponentMixin._renderValidatedComponent @ ReactCompositeComponent.js:737ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:673ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.performUpdateIfNecessary @ ReactCompositeComponent.js:490ReactReconciler.performUpdateIfNecessary @ ReactReconciler.js:112obj.(anonymous function) @ backend.js:2130runBatchedUpdates @ ReactUpdates.js:149Mixin.perform @ Transaction.js:140Mixin.perform @ Transaction.js:140assign.perform @ ReactUpdates.js:93flushBatchedUpdates @ ReactUpdates.js:173ReactPerf.measure.wrapper @ ReactPerf.js:70Mixin.closeAll @ Transaction.js:213Mixin.perform @ Transaction.js:154ReactDefaultBatchingStrategy.batchedUpdates @ ReactDefaultBatchingStrategy.js:66batchedUpdates @ ReactUpdates.js:108(anonymous function) @ MessageQueue.js:82guard @ MessageQueue.js:39processBatch @ MessageQueue.js:81messageHandlers.executeJSCall @ debugger-ui:66ws.onmessage @ debugger-ui:93
ExceptionsManager.js:65 Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `Navigator`.
 stack: 
  instantiateReactComponent                          index.ios.bundle:8205
  Object.ReactChildReconciler.instantiateChildren    index.ios.bundle:22403
  ReactMultiChild.Mixin.mountChildren                index.ios.bundle:22112
  ReactNativeBaseComponent.Mixin.initializeChildren  index.ios.bundle:19420
  ReactNativeBaseComponent.Mixin.mountComponent      index.ios.bundle:19585
  Object.ReactReconciler.mountComponent              index.ios.bundle:6713
  Object.obj.(anonymous                              backend.js:2130
  ReactCompositeComponentMixin.mountComponent        index.ios.bundle:8511
  ReactPerf.measure.wrapper [as mountComponent]      index.ios.bundle:5875
 URL: undefined
 line: undefined
 message: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `Navigator`.
0reactions
ivanbrenscommented, Nov 18, 2015

+1, this solution rocks. Thanks @ericvicenti and @kevinzzz007

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native this.props.navigator.push can't push a component ...
Alpha and Beta don't need each other until the user navigates from one scene to the next. For the app to reach this...
Read more >
React navigation prevent double push() - Stack Overflow
1. The app has multiple stack navigators. So there are a lots of navigation.push('Routename') calls. Trouble is when the control surface ( ...
Read more >
Access the navigation prop from any component
useNavigation is a hook which gives access to the navigation object. It's useful when you cannot pass the navigation prop into the component...
Read more >
react-router v6 demystified (part 2) - DEV Community ‍ ‍
The solution is to store the location in a state and change it when we navigate through the pages. But we can't just...
Read more >
Handling Mounting And Unmounting Of Navigation Routes In ...
Custom components in React Native (how to create components, receive, pass, and use props in a component). Read more. React Navigation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found