Skip to content

Commit

Permalink
fix: switchScrollingEffect call error when getContainer is false (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong authored and afc163 committed Dec 13, 2019
1 parent f186eef commit 9e3a01c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/DrawerChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ interface IState {
}

class DrawerChild extends React.Component<IDrawerChildProps, IState> {
static defaultProps = {
switchScrollingEffect: () => {},
}

public static getDerivedStateFromProps(props: IDrawerChildProps,
{ prevProps, _self }: { prevProps: IDrawerChildProps, _self: DrawerChild }) {
const nextState = {
Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rc-drawer-menu getContainer 1`] = `
<div
class="div-wrapper"
/>
`;

exports[`rc-drawer-menu getContainer is null 1`] = `
<div
class="react-wrapper"
Expand Down
13 changes: 11 additions & 2 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import * as React from 'react';
import toJson from 'enzyme-to-json';
import Drawer from '../src/';

function Div(props: { show?: boolean }) {
function Div(props) {
const { show, ...otherProps } = props
return (
<div className="div-wrapper">
{props.show && <Drawer wrapperClassName="drawer-wrapper" defaultOpen={true} />}
{show && <Drawer wrapperClassName="drawer-wrapper" defaultOpen {...otherProps} />}
</div>
);
}
Expand Down Expand Up @@ -187,4 +188,12 @@ describe('rc-drawer-menu', () => {
instance = mount(<Drawer handler={null} levelMove={200} />);
expect(toJson(instance.render())).toMatchSnapshot();
});

it('getContainer', () => {
instance = mount(<Div show getContainer={false} />);
instance.setProps({
show: false,
});
expect(toJson(instance.render())).toMatchSnapshot();
});
});

1 comment on commit 9e3a01c

@vercel
Copy link

@vercel vercel bot commented on 9e3a01c Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.