Skip to content

Commit 9e3a01c

Browse files
shaodahongafc163
authored andcommitted
fix: switchScrollingEffect call error when getContainer is false (#122)
1 parent f186eef commit 9e3a01c

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/DrawerChild.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ interface IState {
2828
}
2929

3030
class DrawerChild extends React.Component<IDrawerChildProps, IState> {
31+
static defaultProps = {
32+
switchScrollingEffect: () => {},
33+
}
34+
3135
public static getDerivedStateFromProps(props: IDrawerChildProps,
3236
{ prevProps, _self }: { prevProps: IDrawerChildProps, _self: DrawerChild }) {
3337
const nextState = {

tests/__snapshots__/index.spec.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`rc-drawer-menu getContainer 1`] = `
4+
<div
5+
class="div-wrapper"
6+
/>
7+
`;
8+
39
exports[`rc-drawer-menu getContainer is null 1`] = `
410
<div
511
class="react-wrapper"

tests/index.spec.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import * as React from 'react';
33
import toJson from 'enzyme-to-json';
44
import Drawer from '../src/';
55

6-
function Div(props: { show?: boolean }) {
6+
function Div(props) {
7+
const { show, ...otherProps } = props
78
return (
89
<div className="div-wrapper">
9-
{props.show && <Drawer wrapperClassName="drawer-wrapper" defaultOpen={true} />}
10+
{show && <Drawer wrapperClassName="drawer-wrapper" defaultOpen {...otherProps} />}
1011
</div>
1112
);
1213
}
@@ -187,4 +188,12 @@ describe('rc-drawer-menu', () => {
187188
instance = mount(<Drawer handler={null} levelMove={200} />);
188189
expect(toJson(instance.render())).toMatchSnapshot();
189190
});
191+
192+
it('getContainer', () => {
193+
instance = mount(<Div show getContainer={false} />);
194+
instance.setProps({
195+
show: false,
196+
});
197+
expect(toJson(instance.render())).toMatchSnapshot();
198+
});
190199
});

0 commit comments

Comments
 (0)