react-native: React Native this.props.navigator.push can't push a component twice for Navigator

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?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

@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`.