From bd1827822e37a859d6f704508dd17baedb26911f Mon Sep 17 00:00:00 2001 From: AdrianFleming <48060111+AdrianFleming@users.noreply.github.com> Date: Thu, 25 Jul 2019 13:47:43 +0100 Subject: [PATCH 1/3] Update SwitchTransition-test.js Add test for null key --- test/SwitchTransition-test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/SwitchTransition-test.js b/test/SwitchTransition-test.js index 744e2967..3f2c98f3 100644 --- a/test/SwitchTransition-test.js +++ b/test/SwitchTransition-test.js @@ -43,6 +43,18 @@ describe('SwitchTransition', () => { expect(wrapper.state('status')).toBe(ENTERED); }); + it('should have default status ENTERED', () => { + const wrapper = mount( + + + + + + ); + + expect(wrapper.state('status')).toBe(ENTERED); + }); + it('should have default mode: out-in', () => { const wrapper = mount( From 4419643e74b0c269c87bd00d33101637f67b30eb Mon Sep 17 00:00:00 2001 From: AdrianFleming <48060111+AdrianFleming@users.noreply.github.com> Date: Thu, 25 Jul 2019 13:50:39 +0100 Subject: [PATCH 2/3] Update SwitchTransition.js If this was called with a key of the Router's location.key and this is null then the children were not equal and the transition was repeatedly fading in and out. This could be seen by opening a new window and browsing to a site where the user had a valid token. --- src/SwitchTransition.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SwitchTransition.js b/src/SwitchTransition.js index 0fdfc6c4..1497e40c 100644 --- a/src/SwitchTransition.js +++ b/src/SwitchTransition.js @@ -8,8 +8,7 @@ function areChildrenDifferent(oldChildren, newChildren) { if ( React.isValidElement(oldChildren) && React.isValidElement(newChildren) && - oldChildren.key != null && - oldChildren.key === newChildren.key + ((oldChildren.key == null && newChildren.key == null) || oldChildren.key === newChildren.key) ) { return false; } From f3cc4336db6ad8fe83cacdeb381aa1c1455829ca Mon Sep 17 00:00:00 2001 From: AdrianFleming <48060111+AdrianFleming@users.noreply.github.com> Date: Thu, 25 Jul 2019 14:21:28 +0100 Subject: [PATCH 3/3] Update SwitchTransition-test.js Fix broken build, {null} not null --- test/SwitchTransition-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SwitchTransition-test.js b/test/SwitchTransition-test.js index 3f2c98f3..f0ab9b7c 100644 --- a/test/SwitchTransition-test.js +++ b/test/SwitchTransition-test.js @@ -46,7 +46,7 @@ describe('SwitchTransition', () => { it('should have default status ENTERED', () => { const wrapper = mount( - +