From bc01a4cd5701fd6f73861c14a578131950061f28 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Wed, 27 Jun 2018 17:35:29 -0700 Subject: [PATCH] Throw error in development mode when title is not a string --- CHANGELOG.md | 1 + src/views/Header/Header.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f993508..de95515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] - Throw error in development mode when header navigation option is set to a string - a common mistake that would otherwise result in a cryptic error message. - Update react-navigation-drawer to 0.4.3 to fix `initialRouteParams` option +- Throw error in development mode when title is not a string. ## [2.5.4] - [2018-06-27](https://github.com/react-navigation/react-navigation/releases/tag/2.5.4) ### Fixed diff --git a/src/views/Header/Header.js b/src/views/Header/Header.js index 8cbb2f7..d129264 100644 --- a/src/views/Header/Header.js +++ b/src/views/Header/Header.js @@ -55,6 +55,15 @@ class Header extends React.PureComponent { if (typeof options.headerTitle === 'string') { return options.headerTitle; } + + if (options.title && typeof options.title !== 'string' && __DEV__) { + throw new Error( + `Invalid title for route "${ + scene.route.routeName + }" - title must be string or null, instead it was of type ${typeof options.title}` + ); + } + return options.title; }