react-hot-toast
react-hot-toast copied to clipboard
Toasts do not render correctly when <Toaster> renders after toasts are created
Showcase: https://share.commandbar.com/vsXPEw
Steps to reproduce:
- queue up two or more toasts before rendering a
<Toaster>
component - render a
<Toaster>
component
Expected result:
Toasts are shown immediately after rendering <Toaster>
Actual result: Either (a) no toasts are shown; or (b) the toasts are "stacked up" on top of each other.
Example app demonstrating issue:
import toast, { Toaster } from 'react-hot-toast';
import React, {useState} from 'react';
import logo from './logo.svg';
import './App.css';
toast.success("Hello World!", {id: "1", duration: Infinity})
toast.success("Goodbye world!", {id: "2", duration: Infinity})
function App() {
const [state, setState] = useState(false);
console.log("App re-render", state);
return (
<div>
<button onClick={(() => {
setState(x => !x)
})}>toggle toaster</button>
{state && <Toaster />}
</div>
);
}
export default App;
Full demo app here: https://replit.com/@JaredLuxenberg/react-hot-toast-gh-issue-253