2016-09-20 27 views
9

我想獲得視圖之間導航工作作出反應原住民像這樣:導航不工作的陣營原生應用(參數0(NSNumber的))

newUserFlow() { 
    this.props.navigator.push({ 
     title: "Create Account", 
     component: F8InfoView, 
    }); 
    } 

<TopFiveButton 
      style={styles.button} 
      onPress={this.newUserFlow.bind(this)} 
      caption="Create Account" 
/> 

不過,我遇到了在點擊這個錯誤:

ExceptionsManager.js:75 Argument 0 (NSNumber) of RCTNavigatorManager.requestSchedulingJavaScriptNavigation must not be null 

這工作以前,但似乎有所改變。可能是什麼問題?謝謝。

調試器引用這在例外經理:

// Flow doesn't like it when you set arbitrary values on a global object 
    (console: any)._errorOriginal = console.error.bind(console); 

我會打破流量的東西嗎?謝謝。

編輯:

index.ios.js看起來是這樣的:

class nomad extends Component { 
    render() { 
    return (
     <NavigatorIOS 
     style={styles.container} 
     initialRoute={{ 
      title: 'Nomad', 
      component: LoginScreen 
     }} /> 
    ); 
    } 
}; 

然後在LoginScreen:

class LoginScreen extends React.Component { 
    newUserFlow() { 
    this.props.navigator.push({ 
     title: "Create Account", 
     component: F8InfoView, 
//  passProps: {userInfo: this.props.userInfo} 
    }) 
    } 
render() { 
    return (
      <F8Button 
      style={styles.button} 
      onPress={this.newUserFlow.bind(this)} 
      caption="Create Account" 
      /> 
    ); 
    } 
} 

單擊該按鈕給我的錯誤。

+0

什麼是你'renderScene'外觀就像在你的「導航器」中一樣? – rclai

+0

我沒有在render()函數中使用Navigator組件。我只是調用該函數(newUserFlow()),並使用this.props.navigator.push命令推入組件F8InfoView。 – user1072337

+0

這是一個按鈕。我已經使用NavigatorIOS以組件視圖初始化應用程序。 – user1072337

回答

0

您使用哪個版本進行反應?你確定要上最後一個穩定的版本嗎?我問你的話,因爲ExceptionsManager.js,我看不到「NSNumber的」上線75 ...

讓我強調,this question很相似......所以你試圖把

navigator.push(routes[1]); 

內onPress道具。 ?

類似:

<F8Button onPress={ 
    () => { if (route.index === 0){ 
        navigator.push(routes[1]); 
       } else { 
        navigator.pop(); 
       } 
      } 
... 
... 

總之,你也可能有在https://facebook.github.io/react-native/docs/navigator.html

問候

-1

希望這個解決方案可以幫助你一點可能有

問題細看發生

問題是,一旦您執行onPressevent,i索引超出範圍,因此無法找到節點。 有些東西告訴我發生了這種情況,因爲您試圖訪問ref爲null,因爲您將dropdown列表放在導航器的renderScene函數中。我有同樣的問題。

請考慮發佈您的代碼或調試findNodeHandle結果,因爲一旦您將null作爲節點發送,就會產生此錯誤。

由於React無法找到該節點,因此findNodeHandle未將React節點作爲參數,可能會導致錯誤。

這可能是您向節點發送空節點的問題。嘗試調試您在findNodeHandle函數中獲得的內容。

解決方案

你必須對所有裁判更改爲this.refs.navigator.refs['any reference made in your code']

不要忘了給實際導航中的Ref

<Navigator 
ref='navigator'