From 432e0f83e93003d9d8d007b2ea87e42ed4c8d9a3 Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Sun, 14 Apr 2019 08:47:01 +1000 Subject: [PATCH] fix: dont skip first update or plain components --- src/reactHotLoader.js | 4 +--- test/reactHotLoader.test.js | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/reactHotLoader.js b/src/reactHotLoader.js index 7613339f5..6d499ca66 100644 --- a/src/reactHotLoader.js +++ b/src/reactHotLoader.js @@ -46,9 +46,6 @@ const reactHotLoader = { const proxy = getProxyById(id) if (proxy && proxy.getCurrent() !== type) { - // component got replaced. Need to reconcile - incrementGeneration() - if (!reactHotLoader.IS_REACT_MERGE_ENABLED) { if ( isTypeBlacklisted(type) || @@ -74,6 +71,7 @@ const reactHotLoader = { registerComponent(updateProxyById(id, type, options).get(), 2) registerComponent(type) + incrementGeneration() } if (isContextType({ type })) { // possible options - Context, Consumer, Provider. diff --git a/test/reactHotLoader.test.js b/test/reactHotLoader.test.js index 9437f59fb..23520c727 100644 --- a/test/reactHotLoader.test.js +++ b/test/reactHotLoader.test.js @@ -112,16 +112,16 @@ describe('reactHotLoader', () => { const oldGeneration = getGeneration() reactHotLoader.register(Div, 'Div', 'reactHotLoader.test.js') // new thing, no change - expect(getGeneration()).toBe(oldGeneration + 0) + expect(getGeneration()).toBe(oldGeneration + 1) reactHotLoader.register(Div, 'Div', 'reactHotLoader.test.js') // no replacement - expect(getGeneration()).toBe(oldGeneration + 0) + expect(getGeneration()).toBe(oldGeneration + 2) const NewDiv = () =>
reactHotLoader.register(NewDiv, 'Div', 'reactHotLoader.test.js') // replacement! - expect(getGeneration()).toBe(oldGeneration + 1) + expect(getGeneration()).toBe(oldGeneration + 3) }) it('should ignore dom elements and incomplete signature', () => {