Skip to content

Instantly share code, notes, and snippets.

@juanlatorre
Created October 29, 2020 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanlatorre/2a5f3957bb8510f29749f2dc3e7b899f to your computer and use it in GitHub Desktop.
Save juanlatorre/2a5f3957bb8510f29749f2dc3e7b899f to your computer and use it in GitHub Desktop.
diff --git a/node_modules/@chakra-ui/toast/dist/esm/toast-manager.js b/node_modules/@chakra-ui/toast/dist/esm/toast-manager.js
index f64ed90..af3e367 100644
--- a/node_modules/@chakra-ui/toast/dist/esm/toast-manager.js
+++ b/node_modules/@chakra-ui/toast/dist/esm/toast-manager.js
@@ -119,9 +119,18 @@ export class ToastManager extends React.Component {
var position = getToastPosition(prevState, id);
if (!position) return prevState;
return _extends({}, prevState, {
- [position]: prevState[position].map(toast => _extends({}, toast, {
- requestClose: toast.id === id ? true : toast.requestClose
- }))
+ [position]: prevState[position].map((toast) => {
+ // id may be string or number
+ // eslint-disable-next-line eqeqeq
+ if (toast.id == id) {
+ return {
+ ...toast,
+ requestClose: true,
+ }
+ }
+
+ return toast
+ }),
});
});
});
@@ -129,7 +138,7 @@ export class ToastManager extends React.Component {
_defineProperty(this, "removeToast", (id, position) => {
this.setState(prevState => {
return _extends({}, prevState, {
- [position]: prevState[position].filter(toast => toast.id !== id)
+ [position]: prevState[position].filter(toast => toast.id != id)
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment