fix: Catch error when emoji combinations cause document to be unable to persist (#3250)

* fix: Catch and warn of rare error when emoji combinations cause document to be unable to persist changes
closes #3230

* addEventListener -> removeEventListener
This commit is contained in:
Tom Moor
2022-03-16 15:18:16 -07:00
committed by GitHub
parent a27af88d4a
commit 76e1869ebf
3 changed files with 33 additions and 5 deletions

View File

@@ -17,7 +17,12 @@ function Toast({ closeAfterMs = 3000, onRequestClose, toast }: Props) {
const { action, type = "info", reoccurring } = toast;
React.useEffect(() => {
timeout.current = setTimeout(onRequestClose, toast.timeout || closeAfterMs);
if (toast.timeout) {
timeout.current = setTimeout(
onRequestClose,
toast.timeout || closeAfterMs
);
}
return () => timeout.current && clearTimeout(timeout.current);
}, [onRequestClose, toast, closeAfterMs]);
@@ -36,7 +41,7 @@ function Toast({ closeAfterMs = 3000, onRequestClose, toast }: Props) {
}, []);
const handleResume = React.useCallback(() => {
if (timeout.current) {
if (timeout.current && toast.timeout) {
timeout.current = setTimeout(
onRequestClose,
toast.timeout || closeAfterMs