Skip to content

Commit dc44c02

Browse files
committed
chore: Use latest rc-motion
1 parent ed597ae commit dc44c02

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"devDependencies": {
5050
"@types/classnames": "^2.2.10",
51+
"@types/enzyme": "^3.10.7",
5152
"@types/jest": "^26.0.4",
5253
"@types/react": "^16.9.34",
5354
"@types/react-dom": "^16.9.7",
@@ -65,7 +66,7 @@
6566
"dependencies": {
6667
"@babel/runtime": "^7.10.1",
6768
"classnames": "2.x",
68-
"rc-motion": "^2.1.1",
69+
"rc-motion": "^2.2.0",
6970
"rc-util": "^5.0.1"
7071
}
7172
}

src/Notification.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ class Notification extends Component<NotificationProps, NotificationState> {
165165
<CSSMotionList
166166
keys={noticeKeys}
167167
motionName={this.getTransitionName()}
168-
onLeaveEnd={(_, __, { key }) => {
169-
delete this.noticePropsMap[key];
168+
onVisibleChanged={(changedVisible, { key }) => {
169+
if (!changedVisible) {
170+
delete this.noticePropsMap[key];
171+
}
170172
}}
171173
>
172174
{({ key, className: motionClassName, style: motionStyle }) => {
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { mount } from 'enzyme';
2+
import { mount, ReactWrapper } from 'enzyme';
33
import Notification from '../src';
4+
import { NotificationInstance } from '../src/Notification';
45

56
require('../assets/index.less');
67

@@ -12,13 +13,21 @@ async function timeout(delay = 0) {
1213

1314
describe('Notification.Hooks', () => {
1415
it('works', async () => {
15-
let instance;
16+
let instance: NotificationInstance;
1617

1718
const Context = React.createContext({ name: 'light' });
1819

19-
Notification.newInstance({}, notification => {
20-
instance = notification;
21-
});
20+
let wrapper: ReactWrapper;
21+
Notification.newInstance(
22+
{
23+
TEST_RENDER: (node: React.ReactElement) => {
24+
wrapper = mount(<div>{node}</div>);
25+
},
26+
} as any,
27+
notification => {
28+
instance = notification;
29+
},
30+
);
2231

2332
await timeout(0);
2433

@@ -30,6 +39,7 @@ describe('Notification.Hooks', () => {
3039
type="button"
3140
onClick={() => {
3241
notify({
42+
duration: 0.1,
3343
content: (
3444
<Context.Consumer>
3545
{({ name }) => <div className="context-content">{name}</div>}
@@ -50,6 +60,8 @@ describe('Notification.Hooks', () => {
5060
expect(demo.find('.context-content').text()).toEqual('bamboo');
5161

5262
await timeout(1000);
63+
expect(wrapper.find('Notification').state().notices).toHaveLength(0);
64+
5365
instance.destroy();
5466
});
5567
});

0 commit comments

Comments
 (0)