Throw error in development mode when title is not a string

This commit is contained in:
Brent Vatne 2018-06-27 17:35:29 -07:00
parent cad3d70aed
commit bc01a4cd57
2 changed files with 10 additions and 0 deletions

View File

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

View File

@ -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;
}