fix: handle invalid Algolia keys gracefully in dev (#37088)

Invalid keys throw an error in production, but just cause invalid
PropTypes and build warnings in development.
This commit is contained in:
Oliver Eyton-Williams
2019-10-08 10:19:43 +02:00
committed by mrugesh
parent 4889e0fdc6
commit e72855dad3
4 changed files with 28 additions and 7 deletions

View File

@@ -20,7 +20,11 @@ import { createSelector } from 'reselect';
const DEBOUNCE_TIME = 100;
const searchClient = algoliasearch(algoliaAppId, algoliaAPIKey);
// If a key is missing, searches will fail, but the client will still render.
const searchClient =
algoliaAppId && algoliaAPIKey
? algoliasearch(algoliaAppId, algoliaAPIKey)
: {};
const propTypes = {
children: PropTypes.any,