From bb5719f4388e3778ed2afcd3268cc2b35a828773 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Wed, 27 Jun 2018 17:22:00 -0700 Subject: [PATCH] Throw an error when header is invalid --- CHANGELOG.md | 1 + src/views/StackView/StackViewLayout.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87179958..1d827360 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/views/StackView/StackViewLayout.js b/src/views/StackView/StackViewLayout.js index 1d4f9310..455a3ca5 100644 --- a/src/views/StackView/StackViewLayout.js +++ b/src/views/StackView/StackViewLayout.js @@ -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; }