From 9e3a01c48737a96847847eb6c3aabeb6dfeaea22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AA=97=E4=BD=A0=E6=98=AF=E5=B0=8F=E7=8C=AB=E5=92=AA?= Date: Fri, 13 Dec 2019 20:42:26 +0800 Subject: [PATCH] fix: switchScrollingEffect call error when getContainer is false (#122) --- src/DrawerChild.tsx | 4 ++++ tests/__snapshots__/index.spec.tsx.snap | 6 ++++++ tests/index.spec.tsx | 13 +++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/DrawerChild.tsx b/src/DrawerChild.tsx index 07d36c88..cec41de9 100644 --- a/src/DrawerChild.tsx +++ b/src/DrawerChild.tsx @@ -28,6 +28,10 @@ interface IState { } class DrawerChild extends React.Component { + static defaultProps = { + switchScrollingEffect: () => {}, + } + public static getDerivedStateFromProps(props: IDrawerChildProps, { prevProps, _self }: { prevProps: IDrawerChildProps, _self: DrawerChild }) { const nextState = { diff --git a/tests/__snapshots__/index.spec.tsx.snap b/tests/__snapshots__/index.spec.tsx.snap index 34c30a72..1d9499a9 100644 --- a/tests/__snapshots__/index.spec.tsx.snap +++ b/tests/__snapshots__/index.spec.tsx.snap @@ -1,5 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`rc-drawer-menu getContainer 1`] = ` +
+`; + exports[`rc-drawer-menu getContainer is null 1`] = `
- {props.show && } + {show && }
); } @@ -187,4 +188,12 @@ describe('rc-drawer-menu', () => { instance = mount(); expect(toJson(instance.render())).toMatchSnapshot(); }); + + it('getContainer', () => { + instance = mount(
); + instance.setProps({ + show: false, + }); + expect(toJson(instance.render())).toMatchSnapshot(); + }); });