Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switchScrollingEffect call error when getContainer is false #122

Merged
merged 1 commit into from Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/DrawerChild.tsx
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
@@ -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
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();
});
});