Skip to content

Commit

Permalink
toast to single instance, close #745
Browse files Browse the repository at this point in the history
  • Loading branch information
silentcloud committed Jan 19, 2017
1 parent 62f75f8 commit 6dd591a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import topView from 'rn-topview';
import ToastContainer from './ToastContainer';

function notice(content, type, duration = 3, onClose, mask = true) {
topView.remove();
topView.set(
<ToastContainer
content={content}
Expand Down
4 changes: 4 additions & 0 deletions components/toast/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ let messageInstance;
let prefixCls = 'am-toast';

function getMessageInstance(mask) {
if (messageInstance) {
messageInstance.destroy();
messageInstance = null;
}
messageInstance = (Notification as any).newInstance({
prefixCls,
style: { top: (mask ? 0 : '50%') },
Expand Down

0 comments on commit 6dd591a

Please sign in to comment.