Throw an error when header is invalid

This commit is contained in:
Brent Vatne
2018-06-27 17:22:00 -07:00
parent 3dd3f5b804
commit bb5719f438
2 changed files with 7 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [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.
## [2.5.4] - [2018-06-27](https://github.com/react-navigation/react-navigation/releases/tag/2.5.4)
### Fixed

View File

@@ -120,6 +120,12 @@ class StackViewLayout extends React.Component {
const { options } = scene.descriptor;
const { header } = options;
if (__DEV__ && typeof header === 'string') {
throw new Error(
`Invalid header value: "${header}". The header option must be a valid React component or null, not a string.`
);
}
if (header === null && headerMode === 'screen') {
return null;
}