LoginSignup
3
0

More than 5 years have passed since last update.

【react-navigation】2.5.5のヘッダー仕様

Last updated at Posted at 2018-07-05

何が起きたか

react-navigationのヘッダーにImageを使用したくて以下のようにしていた

navigationOptions: {
  title: (
      <Image source={xxx}/>
  ),
}

2.5.5に上げるとエラー

エラー内容

- title must be string or null, instead it was of type 

image.png

これは2.5.4以前の仕様では問題なく動作していました。

2.5.5になると

titleオプションではstring以外受け付けないようになりました。開発モードではエラーになります。
該当コミット: bc01a4c
image.png

どうするか

コミッターに聞いたところ、headerTitleオプションを代わりに使うようにとのコメントがありました。
titleはあくまで文字列専用にして、それ以外はheaderTitleで扱うような使い分けかもしれません。

navigationOptions: {
  headerTitle: (
      <Image source={xxx}/>
  ),
}

備忘録として。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0