Skip to content

Commit

Permalink
toast uuid issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lvshaoping007 committed Sep 9, 2021
1 parent 9018ff0 commit accdcac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 2 additions & 11 deletions src/popup/component/Toast/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ class ToastContainer extends Component {
}

pushToast = (toastProps) => {
const { type, text, duration, isShowMask = false } = toastProps;
const { text, duration, isShowMask = false } = toastProps;
let lastDuration = duration || default_duration
this.setState({
currentToast: {
id: getUuid(),
type,
text,
duration: lastDuration,
isShowMask
Expand All @@ -37,7 +35,7 @@ class ToastContainer extends Component {
}

render() {
const { toastList, isShowMask, currentToast } = this.state;
const { isShowMask, currentToast } = this.state;
return (
<div className="toast-container">
{isShowMask && <div className="mask" />}
Expand All @@ -49,11 +47,4 @@ class ToastContainer extends Component {
}
}

let toastCount = 0;


const getUuid = () => {
return 'toast-container' + new Date().getTime() + '-' + toastCount++;
};

export default ToastContainer;
4 changes: 2 additions & 2 deletions src/popup/component/Toast/ToastItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import "./ToastItem.scss";

class ToastItem extends Component {
componentDidMount() {
const { id, duration, onClose, isShowMask } = this.props;
const { duration, onClose} = this.props;
this.timer = setTimeout(() => {
if (onClose) {
onClose(id, isShowMask);
onClose();
}
}, duration)
}
Expand Down

0 comments on commit accdcac

Please sign in to comment.