├── .editorconfig
├── .gitignore
├── .travis.yml
├── HISTORY.md
├── LICENSE.md
├── README.md
├── assets
└── index.less
├── examples
├── simple.html
└── simple.js
├── index.js
├── package.json
├── src
├── Notice.jsx
├── Notification.jsx
└── index.js
└── tests
└── index.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # top-most EditorConfig file
2 | root = true
3 |
4 | # Unix-style newlines with a newline ending every file
5 | [*.{js,css}]
6 | end_of_line = lf
7 | insert_final_newline = true
8 | indent_style = space
9 | indent_size = 2
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.log
3 | *.log.*
4 | .idea/
5 | .ipr
6 | .iws
7 | *~
8 | ~*
9 | *.diff
10 | *.patch
11 | *.bak
12 | .DS_Store
13 | Thumbs.db
14 | .project
15 | .*proj
16 | .svn/
17 | *.swp
18 | *.swo
19 | *.pyc
20 | *.pyo
21 | .build
22 | node_modules
23 | .cache
24 | dist
25 | assets/**/*.css
26 | build
27 | lib
28 | es
29 | coverage
30 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | sudo: false
4 |
5 | notifications:
6 | email:
7 | - yiminghe@gmail.com
8 | - hust2012jiangkai@gmail.com
9 |
10 | node_js:
11 | - 6
12 |
13 | before_install:
14 | - |
15 | if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
16 | then
17 | echo "Only docs were updated, stopping build process."
18 | exit
19 | fi
20 | npm install npm@3.x -g
21 | phantomjs --version
22 | script:
23 | - |
24 | if [ "$TEST_TYPE" = test ]; then
25 | npm test
26 | else
27 | npm run $TEST_TYPE
28 | fi
29 | env:
30 | matrix:
31 | - TEST_TYPE=lint
32 | - TEST_TYPE=test
33 | - TEST_TYPE=coverage
34 |
35 |
36 | matrix:
37 | allow_failures:
38 | - env: "TEST_TYPE=saucelabs"
39 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | ## 2.0.0
2 |
3 | - [Beack Change] Remove wrapper span element when just single notification. [#17](https://github.com/react-component/notification/pull/17)
4 |
5 | ## 1.4.0
6 |
7 | - Added `getContainer` property.
8 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-present yiminghe
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rmc-notification
2 | ---
3 |
4 | React Notification UI Component
5 |
6 | [![NPM version][npm-image]][npm-url]
7 | [![build status][travis-image]][travis-url]
8 | [![Test coverage][coveralls-image]][coveralls-url]
9 | [![gemnasium deps][gemnasium-image]][gemnasium-url]
10 | [![node version][node-image]][node-url]
11 | [![npm download][download-image]][download-url]
12 |
13 | [npm-image]: http://img.shields.io/npm/v/rmc-notification.svg?style=flat-square
14 | [npm-url]: http://npmjs.org/package/rmc-notification
15 | [travis-image]: https://img.shields.io/travis/react-component/m-notification.svg?style=flat-square
16 | [travis-url]: https://travis-ci.org/react-component/m-notification
17 | [coveralls-image]: https://img.shields.io/coveralls/react-component/m-notification.svg?style=flat-square
18 | [coveralls-url]: https://coveralls.io/r/react-component/m-notification?branch=master
19 | [gemnasium-image]: http://img.shields.io/gemnasium/react-component/m-notification.svg?style=flat-square
20 | [gemnasium-url]: https://gemnasium.com/react-component/m-notification
21 | [node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
22 | [node-url]: http://nodejs.org/download/
23 | [download-image]: https://img.shields.io/npm/dm/rmc-notification.svg?style=flat-square
24 | [download-url]: https://npmjs.org/package/rmc-notification
25 |
26 |
27 | ## Development
28 |
29 | ```
30 | npm install
31 | npm start
32 | ```
33 |
34 | ## Example
35 |
36 | http://localhost:8000/examples/
37 |
38 | online example: http://react-component.github.io/m-notification/examples/
39 |
40 |
41 | ## Feature
42 |
43 | * support ie8,ie8+,chrome,firefox,safari
44 |
45 |
46 | ## install
47 |
48 | [](https://npmjs.org/package/rmc-notification)
49 |
50 | ## Usage
51 |
52 | ```js
53 | var Notification = require('rmc-notification');
54 | Notification.newInstance({}, notification => {
55 | notification.notice({
56 | content: 'content'
57 | });
58 | });
59 | ```
60 |
61 | ## API
62 |
63 | ### Notification.newInstance(props, (notification) => void) => void
64 |
65 | props details:
66 |
67 |
68 |
69 |
70 | name |
71 | type |
72 | default |
73 | description |
74 |
75 |
76 |
77 |
78 | prefixCls |
79 | String |
80 | |
81 | prefix class name for notification container |
82 |
83 |
84 | style |
85 | Object |
86 | {'top': 65, left: '50%'} |
87 | additional style for notification container. |
88 |
89 |
90 | getContainer |
91 | getContainer(): HTMLElement |
92 | |
93 | function returning html node which will act as notification container |
94 |
95 |
96 |
97 |
98 | ### notification.notice(props)
99 |
100 | props details:
101 |
102 |
103 |
104 |
105 | name |
106 | type |
107 | default |
108 | description |
109 |
110 |
111 |
112 |
113 | content |
114 | React.Element |
115 | |
116 | content of notice |
117 |
118 |
119 | key |
120 | String |
121 | |
122 | id of this notice |
123 |
124 |
125 | closable |
126 | Boolean |
127 | |
128 | whether show close button |
129 |
130 |
131 | onClose |
132 | Function |
133 | |
134 | called when notice close |
135 |
136 |
137 | duration |
138 | number |
139 | 1.5 |
140 | after duration of time, this notice will disappear.(seconds) |
141 |
142 |
143 | style |
144 | Object |
145 | { right: '50%' } |
146 | additional style for single notice node. |
147 |
148 |
149 |
150 |
151 | ### notification.removeNotice(key:string)
152 |
153 | remove single notice with specified key
154 |
155 | ### notification.destroy()
156 |
157 | destroy current notification
158 |
159 | ## Test Case
160 |
161 | ```
162 | npm test
163 | npm run chrome-test
164 | ```
165 |
166 | ## Coverage
167 |
168 | ```
169 | npm run coverage
170 | ```
171 |
172 | open coverage/ dir
173 |
174 | ## License
175 |
176 | rmc-notification is released under the MIT license.
177 |
--------------------------------------------------------------------------------
/assets/index.less:
--------------------------------------------------------------------------------
1 | @notificationPrefixCls: rmc-notification;
2 |
3 | .@{notificationPrefixCls} {
4 | position: fixed;
5 | z-index: 1000;
6 |
7 | &-notice {
8 | padding: 7px 20px 7px 10px;
9 | border-radius: 3px 3px;
10 | border: 1px solid #999;
11 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
12 | border: 0px solid rgba(0, 0, 0, 0);
13 | background: #fff;
14 | display: block;
15 | width: auto;
16 | line-height: 1.5;
17 | vertical-align: middle;
18 | position: relative;
19 | margin: 10px 0;
20 |
21 | &-closable {
22 | padding-right: 20px;
23 | }
24 |
25 | &-close {
26 | position: absolute;
27 | right: 5px;
28 | top: 3px;
29 | color: #000;
30 | cursor: pointer;
31 | outline: none;
32 | font-size: 16px;
33 | font-weight: 700;
34 | line-height: 1;
35 | text-shadow: 0 1px 0 #fff;
36 | filter: alpha(opacity=20);
37 | opacity: .2;
38 | text-decoration: none;
39 |
40 | &-x:after {
41 | content: '×';
42 | }
43 |
44 | &:hover {
45 | opacity: 1;
46 | filter: alpha(opacity=100);
47 | text-decoration: none;
48 | }
49 | }
50 | }
51 |
52 | .fade-effect() {
53 | animation-duration: 0.3s;
54 | animation-fill-mode: both;
55 | animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
56 | }
57 |
58 | &-fade-enter {
59 | opacity: 0;
60 | .fade-effect();
61 | animation-play-state: paused;
62 | }
63 |
64 | &-fade-leave {
65 | .fade-effect();
66 | animation-play-state: paused;
67 | }
68 |
69 | &-fade-enter&-fade-enter-active {
70 | animation-name: rcNotificationFadeIn;
71 | animation-play-state: running;
72 | }
73 |
74 | &-fade-leave&-fade-leave-active {
75 | animation-name: rcDialogFadeOut;
76 | animation-play-state: running;
77 | }
78 |
79 | @keyframes rcNotificationFadeIn {
80 | 0% {
81 | opacity: 0;
82 | }
83 | 100% {
84 | opacity: 1;
85 | }
86 | }
87 |
88 | @keyframes rcDialogFadeOut {
89 | 0% {
90 | opacity: 1;
91 | }
92 | 100% {
93 | opacity: 0;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/examples/simple.html:
--------------------------------------------------------------------------------
1 | placeholder
--------------------------------------------------------------------------------
/examples/simple.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-console */
2 | import 'rmc-notification/assets/index.less';
3 | import Notification from 'rmc-notification';
4 | import React from 'react';
5 | import ReactDOM from 'react-dom';
6 | let notification = null;
7 | Notification.newInstance({}, (n) => notification = n);
8 |
9 | function simpleFn() {
10 | notification.notice({
11 | content: simple show,
12 | onClose() {
13 | console.log('simple close');
14 | },
15 | });
16 | }
17 |
18 | function durationFn() {
19 | notification.notice({
20 | content: can not close...,
21 | duration: null,
22 | });
23 | }
24 |
25 | function closableFn() {
26 | notification.notice({
27 | content: closable,
28 | duration: null,
29 | onClose() {
30 | console.log('closable close');
31 | },
32 | closable: true,
33 | });
34 | }
35 |
36 | function close(key) {
37 | notification.removeNotice(key);
38 | }
39 |
40 | function manualClose() {
41 | const key = Date.now();
42 | notification.notice({
43 | content:
44 |
click below button to close
45 |
46 |
,
47 | key,
48 | duration: null,
49 | });
50 | }
51 |
52 | ReactDOM.render(
53 |
54 |
55 |
56 |
57 |
58 |
59 |
, document.getElementById('__react-content'));
60 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./src/');
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rmc-notification",
3 | "version": "1.0.0",
4 | "description": "notification ui component for react",
5 | "keywords": [
6 | "react",
7 | "react-component",
8 | "react-notification",
9 | "notification"
10 | ],
11 | "homepage": "http://github.com/react-component/notification",
12 | "maintainers": [],
13 | "files": [
14 | "dist",
15 | "lib",
16 | "es",
17 | "assets/*.css"
18 | ],
19 | "repository": {
20 | "type": "git",
21 | "url": "git@github.com:react-component/m-notification.git"
22 | },
23 | "bugs": {
24 | "url": "http://github.com/react-component/m-notification/issues"
25 | },
26 | "licenses": "MIT",
27 | "main": "lib/index",
28 | "module": "es/index",
29 | "config": {
30 | "port": 8000,
31 | "entry": {
32 | "rmc-notification": [
33 | "./assets/index.less",
34 | "./src/index.js"
35 | ]
36 | }
37 | },
38 | "scripts": {
39 | "build": "rc-tools run build",
40 | "gh-pages": "rc-tools run gh-pages",
41 | "start": "rc-tools run server",
42 | "compile": "rc-tools run compile --babel-runtime",
43 | "pub": "rc-tools run pub --babel-runtime",
44 | "lint": "rc-tools run lint",
45 | "karma": "rc-test run karma",
46 | "saucelabs": "rc-test run saucelabs",
47 | "test": "rc-test run test",
48 | "chrome-test": "rc-test run chrome-test",
49 | "coverage": "rc-test run coverage"
50 | },
51 | "devDependencies": {
52 | "core-js": "^2.5.1",
53 | "expect.js": "~0.3.1",
54 | "pre-commit": "1.x",
55 | "rc-test": "^6.0.8",
56 | "rc-tools": "^6.3.6",
57 | "react": "^16.0.0",
58 | "react-dom": "^16.0.0"
59 | },
60 | "precommit": [
61 | "lint"
62 | ],
63 | "dependencies": {
64 | "babel-runtime": "6.x",
65 | "classnames": "2.x",
66 | "prop-types": "^15.5.8",
67 | "rc-animate": "2.x",
68 | "rc-util": "^4.0.4"
69 | },
70 | "pre-commit": [
71 | "lint"
72 | ]
73 | }
74 |
--------------------------------------------------------------------------------
/src/Notice.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import classNames from 'classnames';
3 | import PropTypes from 'prop-types';
4 |
5 | export default class Notice extends Component {
6 | static propTypes = {
7 | duration: PropTypes.number,
8 | onClose: PropTypes.func,
9 | children: PropTypes.any,
10 | };
11 |
12 | static defaultProps = {
13 | onEnd() {
14 | },
15 | onClose() {
16 | },
17 | duration: 1.5,
18 | style: {
19 | right: '50%',
20 | },
21 | };
22 |
23 | componentDidMount() {
24 | this.startCloseTimer();
25 | }
26 |
27 | componentWillUnmount() {
28 | this.clearCloseTimer();
29 | }
30 |
31 | close = () => {
32 | this.clearCloseTimer();
33 | this.props.onClose();
34 | }
35 |
36 | startCloseTimer = () => {
37 | if (this.props.duration) {
38 | this.closeTimer = setTimeout(() => {
39 | this.close();
40 | }, this.props.duration * 1000);
41 | }
42 | }
43 |
44 | clearCloseTimer = () => {
45 | if (this.closeTimer) {
46 | clearTimeout(this.closeTimer);
47 | this.closeTimer = null;
48 | }
49 | }
50 |
51 | render() {
52 | const props = this.props;
53 | const componentClass = `${props.prefixCls}-notice`;
54 | const className = {
55 | [`${componentClass}`]: 1,
56 | [`${componentClass}-closable`]: props.closable,
57 | [props.className]: !!props.className,
58 | };
59 | return (
60 |
61 |
{props.children}
62 | {props.closable ?
63 |
64 |
65 | : null
66 | }
67 |
68 | );
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/Notification.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import PropTypes from 'prop-types';
3 | import ReactDOM from 'react-dom';
4 | import Animate from 'rc-animate';
5 | import createChainedFunction from 'rc-util/lib/createChainedFunction';
6 | import classnames from 'classnames';
7 | import Notice from './Notice';
8 |
9 | let seed = 0;
10 | const now = Date.now();
11 |
12 | function getUuid() {
13 | return `rcNotification_${now}_${seed++}`;
14 | }
15 |
16 | class Notification extends Component {
17 | static propTypes = {
18 | prefixCls: PropTypes.string,
19 | transitionName: PropTypes.string,
20 | animation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
21 | style: PropTypes.object,
22 | };
23 |
24 | static defaultProps = {
25 | prefixCls: 'rmc-notification',
26 | animation: 'fade',
27 | style: {
28 | top: 65,
29 | left: '50%',
30 | },
31 | };
32 |
33 | state = {
34 | notices: [],
35 | };
36 |
37 | getTransitionName() {
38 | const props = this.props;
39 | let transitionName = props.transitionName;
40 | if (!transitionName && props.animation) {
41 | transitionName = `${props.prefixCls}-${props.animation}`;
42 | }
43 | return transitionName;
44 | }
45 |
46 | add = (notice) => {
47 | const key = notice.key = notice.key || getUuid();
48 | this.setState(previousState => {
49 | const notices = previousState.notices;
50 | if (!notices.filter(v => v.key === key).length) {
51 | return {
52 | notices: notices.concat(notice),
53 | };
54 | }
55 | });
56 | }
57 |
58 | remove = (key) => {
59 | this.setState(previousState => {
60 | return {
61 | notices: previousState.notices.filter(notice => notice.key !== key),
62 | };
63 | });
64 | }
65 |
66 | render() {
67 | const props = this.props;
68 | const noticeNodes = this.state.notices.map((notice) => {
69 | const onClose = createChainedFunction(this.remove.bind(this, notice.key), notice.onClose);
70 | return (
75 | {notice.content}
76 | );
77 | });
78 | const className = {
79 | [props.prefixCls]: 1,
80 | [props.className]: !!props.className,
81 | };
82 | return (
83 |
86 | );
87 | }
88 | }
89 |
90 | Notification.newInstance = function newNotificationInstance(properties, callback) {
91 | const { getContainer, ...props } = properties || {};
92 | let div;
93 | if (getContainer) {
94 | div = getContainer();
95 | } else {
96 | div = document.createElement('div');
97 | document.body.appendChild(div);
98 | }
99 | let called = false;
100 | function ref(notification) {
101 | if (called) {
102 | return;
103 | }
104 | called = true;
105 | callback({
106 | notice(noticeProps) {
107 | notification.add(noticeProps);
108 | },
109 | removeNotice(key) {
110 | notification.remove(key);
111 | },
112 | component: notification,
113 | destroy() {
114 | ReactDOM.unmountComponentAtNode(div);
115 | if (!getContainer) {
116 | document.body.removeChild(div);
117 | }
118 | },
119 | });
120 | }
121 | ReactDOM.render(, div);
122 | };
123 |
124 | export default Notification;
125 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import Notification from './Notification';
2 | export default Notification;
3 |
--------------------------------------------------------------------------------
/tests/index.js:
--------------------------------------------------------------------------------
1 | import 'core-js/es6/map';
2 | import 'core-js/es6/set';
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import TestUtils from 'react-dom/test-utils';
6 | import expect from 'expect.js';
7 |
8 | import Notification from '../src/';
9 |
10 | require('../assets/index.less');
11 |
12 | describe('rmc-notification', () => {
13 | it('works', (done) => {
14 | Notification.newInstance({}, notification => {
15 | notification.notice({
16 | content: 1
,
17 | duration: 0.1,
18 | });
19 | setTimeout(() => {
20 | expect(
21 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
22 | ).to.be(1);
23 | }, 10);
24 | setTimeout(() => {
25 | expect(
26 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
27 | ).to.be(0);
28 | notification.destroy();
29 | done();
30 | }, 1000);
31 | });
32 | });
33 |
34 | it('works with multi instance', (done) => {
35 | Notification.newInstance({}, notification => {
36 | notification.notice({
37 | content: 1
,
38 | duration: 0.1,
39 | });
40 | notification.notice({
41 | content: 2
,
42 | duration: 0.1,
43 | });
44 | setTimeout(() => {
45 | expect(
46 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
47 | ).to.be(2);
48 | }, 10);
49 | setTimeout(() => {
50 | expect(
51 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
52 | ).to.be(0);
53 | notification.destroy();
54 | done();
55 | }, 1000);
56 | });
57 | });
58 |
59 | it('destroy works', () => {
60 | Notification.newInstance({}, notification => {
61 | notification.notice({
62 | content: 222222
,
63 | duration: 0.1,
64 | });
65 | setTimeout(() => {
66 | expect(
67 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
68 | ).to.be(1);
69 | notification.destroy();
70 | expect(document.getElementById('test')).not.to.be.ok();
71 | }, 10);
72 | });
73 | });
74 |
75 | it('getContainer works', () => {
76 | Notification.newInstance({
77 | getContainer: () => {
78 | const div = document.createElement('div');
79 | div.className = 'rc';
80 | document.body.appendChild(div);
81 | return div;
82 | },
83 | }, notification => {
84 | notification.notice({
85 | content: 222222
,
86 | duration: 1,
87 | });
88 | expect(document.querySelectorAll('.rc').length).to.be(1);
89 | notification.destroy();
90 | });
91 | });
92 |
93 | it('remove notify works', (done) => {
94 | Notification.newInstance({}, notification => {
95 | const key = Date.now();
96 | const close = (k) => {
97 | notification.removeNotice(k);
98 | };
99 | notification.notice({
100 | content:
101 |
104 |
,
105 | key,
106 | duration: null,
107 | });
108 |
109 | setTimeout(() => {
110 | expect(
111 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
112 | ).to.be(1);
113 | const btnClose = document.getElementById('closeButton');
114 | TestUtils.Simulate.click(btnClose);
115 | setTimeout(() => {
116 | expect(
117 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'test').length
118 | ).to.be(0);
119 | notification.destroy();
120 | done();
121 | }, 1000);
122 | }, 10);
123 | });
124 | });
125 |
126 | it('freeze notification layer when mouse over', (done) => {
127 | Notification.newInstance({}, notification => {
128 | notification.notice({
129 | content: freeze
,
130 | duration: 0.3,
131 | });
132 | setTimeout(() => {
133 | expect(document.querySelectorAll('.freeze').length).to.be(1);
134 | const content = document.getElementById('freeze');
135 | TestUtils.Simulate.mouseEnter(content);
136 | setTimeout(() => {
137 | expect(
138 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'freeze').length
139 | ).to.be(1);
140 | TestUtils.Simulate.mouseLeave(content);
141 | setTimeout(() => {
142 | expect(
143 | TestUtils.scryRenderedDOMComponentsWithClass(notification.component, 'freeze').length
144 | ).to.be(0);
145 | notification.destroy();
146 | done();
147 | }, 400);
148 | }, 500);
149 | }, 10);
150 | });
151 | });
152 |
153 | it('should work in lifecycle of React component', () => {
154 | class Test extends React.Component {
155 | componentDidMount() {
156 | Notification.newInstance({}, notification => {
157 | notification.notice({
158 | content: In lifecycle,
159 | });
160 | });
161 | }
162 | render() {
163 | return null;
164 | }
165 | }
166 | const container = document.createElement('div');
167 | document.body.appendChild(container);
168 | expect(() => ReactDOM.render(, container))
169 | .to.not.throwException();
170 | });
171 | });
172 |
--------------------------------------------------------------------------------