From 73eeb4ea357095e2bf42eb6bc7da19db95e201e9 Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Tue, 27 Aug 2019 19:02:50 +1000 Subject: [PATCH] fix: resolve undefined types to undefined, fixes #1324 --- src/reconciler/resolver.js | 11 +++++++++-- test/reactHotLoader.test.js | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/reconciler/resolver.js b/src/reconciler/resolver.js index 88e578f76..e1ce2c58f 100644 --- a/src/reconciler/resolver.js +++ b/src/reconciler/resolver.js @@ -68,5 +68,12 @@ export function resolveNotComponent(type) { export const resolveSimpleType = type => resolveProxy(type) || resolveUtility(type) || type; -export const resolveType = (type, options = {}) => - resolveProxy(type) || resolveUtility(type) || resolveNotComponent(type) || resolveComponent(type, options) || type; +export const resolveType = (type, options = {}) => { + if (!type) { + return type; + } + + return ( + resolveProxy(type) || resolveUtility(type) || resolveNotComponent(type) || resolveComponent(type, options) || type + ); +}; diff --git a/test/reactHotLoader.test.js b/test/reactHotLoader.test.js index c872b8898..8b9383da2 100644 --- a/test/reactHotLoader.test.js +++ b/test/reactHotLoader.test.js @@ -47,6 +47,13 @@ describe('reactHotLoader', () => { const DivProxy = OriginalReactMock.createElement.mock.calls[0][0]; expect(DivProxy[PROXY_KEY]).toBeDefined(); }); + + it('null case', () => { + reactHotLoader.patch(ReactMock); + const result = React.createElement(undefined); + + expect(result.type).toBeUndefined(); + }); }); describe('#createFactory', () => {