Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
r1skz3ro committed Jul 7, 2021
1 parent 0bdd514 commit cddb12d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Toast extends Component {
this.startTimer = this.startTimer.bind(this);
this.animate = this.animate.bind(this);
this.show = this.show.bind(this);
this.displayToast = this.displayToast.bind(this);
this.hide = this.hide.bind(this);
this.onLayout = this.onLayout.bind(this);

Expand Down Expand Up @@ -132,8 +133,9 @@ class Toast extends Component {
const { inProgress: prevInProgress, isVisible: prevIsVisible } = prevState;

if (!inProgress && !isVisible && prevInProgress && prevIsVisible && toastQueue.length > 0) {
toastQueue[toastQueue.length - 1]();
const toastQueueCopy = [...toastQueue].slice(0,-1);

toastQueue[toastQueue.length - 1]();
this.setState({toastQueue: toastQueueCopy})
}
}
Expand Down Expand Up @@ -226,7 +228,7 @@ class Toast extends Component {
const { inProgress, isVisible } = this.state;

if (inProgress || isVisible) {
this.setState({toastQueue: [...this.state.toastQueue, () => this.displayToast(options)]})
this.setState({toastQueue: [...this.state.toastQueue, () => this.displayToast(options)]})
} else {
this.displayToast(options)
}
Expand Down Expand Up @@ -327,7 +329,7 @@ class Toast extends Component {
...config
};

const { type, customProps, inProgress, isVisible } = this.state;
const { type, customProps} = this.state;
const toastComponent = componentsConfig[type];

if (!toastComponent) {
Expand All @@ -338,7 +340,6 @@ class Toast extends Component {
return null;
}


return toastComponent({
...includeKeys({
obj: this.state,
Expand Down

0 comments on commit cddb12d

Please sign in to comment.