RN Exception: Warning: Functions are not valid as a React child. This may happen if you return a ...

異常

ReactNativeJS: Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at Header.js:443)
        in RCTView (at View.js:60)
        in View (at Header.js:488)
        in RCTView (at View.js:60)
        in View (at Header.js:624)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at index.js:134)
        in SafeView (at withOrientation.js:54)
        in withOrientation (at Header.js:622)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at Header.js:611)
        in Header (at withOrientation.js:30)
        in withOrientation (at StackViewLayout.js:154)
        in RCTView (at View.js:60)
        in View (at StackViewLayout.js:780)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at StackViewCard.js:69)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at screens.native.js:58)
        in Screen (at StackViewCard.js:57)
        in Card (at createPointerEventsContainer.js:27)
        in Container (at StackViewLayout.js:858)
        in RCTView (at View.js:60)
        in View (at screens.native.js:83)
        in ScreenContainer (at StackViewLayout.js:311)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at StackViewLayout.js:307)
        in Handler (at StackViewLayout.js:300)
        in StackViewLayout (at withOrientation.js:30)
        in withOrientation (at StackView.js:79)
        in RCTView (at View.js:60)
        in View (at Transitioner.js:215)
        in Transitioner (at StackView.js:22)
        in StackView (created by Navigator)
        in Navigator (at createKeyboardAwareNavigator.js:12)
        in KeyboardAwareNavigator (at createAppContainer.js:388)
        in NavigationContainer (at rootPage.js:84)
        in RootPage (at drawPage.js:112)
        in DrawPage (at TopView.js:202)
        in RCTView (at View.js:60)
        in View (at createAnimatedComponent.js:154)
        in AnimatedComponent (at TopView.js:164)
        in RCTView (at View.js:60)
        in View (at TopView.js:163)
        in TopView (at TopView.js:201)
        in RootElement (at renderApplication.js:33)
        in RCTView (at View.js:60)
        in View (at AppContainer.js:102)
        in RCTView (at View.js:60)
        in View (at AppContainer.js:122)
        in AppContainer (at renderApplication.js:32)

解決方法

  1. 問題代碼

由于 headerRight參數(shù)的值應該為一個組件膜宋,而不是方法默赂,所以會報出此警告。

static navigationOptions = () => ({
    title: '更多',
    headerRight: () => <View />
  });
  1. 解決

將上述代碼改為

  static navigationOptions = () => ({
    title: '更多',
    headerRight: <View />
  });
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市钮糖,隨后出現(xiàn)的幾起案子雀瓢,更是在濱河造成了極大的恐慌枢析,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,270評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件刃麸,死亡現(xiàn)場離奇詭異醒叁,居然都是意外死亡,警方通過查閱死者的電腦和手機泊业,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,489評論 3 395
  • 文/潘曉璐 我一進店門把沼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人吁伺,你說我怎么就攤上這事饮睬。” “怎么了篮奄?”我有些...
    開封第一講書人閱讀 165,630評論 0 356
  • 文/不壞的土叔 我叫張陵捆愁,是天一觀的道長。 經(jīng)常有香客問我窟却,道長昼丑,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,906評論 1 295
  • 正文 為了忘掉前任夸赫,我火速辦了婚禮菩帝,結果婚禮上,老公的妹妹穿的比我還像新娘茬腿。我一直安慰自己呼奢,他們只是感情好,可當我...
    茶點故事閱讀 67,928評論 6 392
  • 文/花漫 我一把揭開白布滓彰。 她就那樣靜靜地躺著控妻,像睡著了一般。 火紅的嫁衣襯著肌膚如雪揭绑。 梳的紋絲不亂的頭發(fā)上弓候,一...
    開封第一講書人閱讀 51,718評論 1 305
  • 那天郎哭,我揣著相機與錄音,去河邊找鬼菇存。 笑死夸研,一個胖子當著我的面吹牛,可吹牛的內容都是我干的依鸥。 我是一名探鬼主播亥至,決...
    沈念sama閱讀 40,442評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼贱迟!你這毒婦竟也來了姐扮?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,345評論 0 276
  • 序言:老撾萬榮一對情侶失蹤衣吠,失蹤者是張志新(化名)和其女友劉穎茶敏,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體缚俏,經(jīng)...
    沈念sama閱讀 45,802評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡惊搏,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,984評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了忧换。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片恬惯。...
    茶點故事閱讀 40,117評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖亚茬,靈堂內的尸體忽然破棺而出酪耳,到底是詐尸還是另有隱情,我是刑警寧澤才写,帶...
    沈念sama閱讀 35,810評論 5 346
  • 正文 年R本政府宣布葡兑,位于F島的核電站,受9級特大地震影響赞草,放射性物質發(fā)生泄漏讹堤。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,462評論 3 331
  • 文/蒙蒙 一厨疙、第九天 我趴在偏房一處隱蔽的房頂上張望洲守。 院中可真熱鬧,春花似錦沾凄、人聲如沸梗醇。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,011評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽叙谨。三九已至,卻和暖如春保屯,著一層夾襖步出監(jiān)牢的瞬間手负,已是汗流浹背涤垫。 一陣腳步聲響...
    開封第一講書人閱讀 33,139評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留竟终,地道東北人蝠猬。 一個月前我還...
    沈念sama閱讀 48,377評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像统捶,于是被迫代替她去往敵國和親榆芦。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,060評論 2 355

推薦閱讀更多精彩內容