From 2549a188b7eb961885c18b158231bbb144f026d7 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 24 Apr 2018 22:52:23 +1000 Subject: [PATCH] fix: condition render in Fragments #942 (#943) --- src/reconciler/hotReplacementRender.js | 2 +- test/AppContainer.dev.test.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/reconciler/hotReplacementRender.js b/src/reconciler/hotReplacementRender.js index 49c87bda1..9c578b70d 100644 --- a/src/reconciler/hotReplacementRender.js +++ b/src/reconciler/hotReplacementRender.js @@ -215,7 +215,7 @@ const mergeInject = (a, b, instance) => { const transformFlowNode = flow => flow.reduce((acc, node) => { if (isFragmentNode(node) && node.props && node.props.children) { - return [...acc, ...node.props.children] + return [...acc, ...filterNullArray(node.props.children)] } return [...acc, node] }, []) diff --git a/test/AppContainer.dev.test.js b/test/AppContainer.dev.test.js index 2743332df..bb1cfd2f4 100644 --- a/test/AppContainer.dev.test.js +++ b/test/AppContainer.dev.test.js @@ -1889,7 +1889,10 @@ describe(`AppContainer (dev)`, () => { const InnerItem = () => ( + {false &&
hole
} -1- + {false &&
hole
} + -3-
) RHL.register(InnerItem, 'InnerItem', 'test.js') @@ -1916,7 +1919,9 @@ describe(`AppContainer (dev)`, () => { , ) - expect(wrapper.update().text()).toBe('1-1-OldInnerComponent3') + expect(wrapper.update().text()).toBe( + '1-1-OldInnerComponent-3-OldInnerComponent3', + ) { class InnerComponent extends Component { componentWillUnmount() { @@ -1932,7 +1937,10 @@ describe(`AppContainer (dev)`, () => { const InnerItem = () => ( + {false &&
hole
} -2- + {false &&
hole
} + -3-
) RHL.register(InnerItem, 'InnerItem', 'test.js') @@ -1940,7 +1948,9 @@ describe(`AppContainer (dev)`, () => { wrapper.setProps({ children: }) } expect(unmount).toHaveBeenCalledTimes(0) - expect(wrapper.update().text()).toBe('1-2-NewInnerComponent3') + expect(wrapper.update().text()).toBe( + '1-2-NewInnerComponent-3-NewInnerComponent3', + ) } else { // React 15 is always ok expect(true).toBe(true)