react-toastify
react-toastify copied to clipboard
Does ToastContainer listen to theme props and auto rerender?
I have a usage like this:
const [darkMode, setDarkMode] = useState(false)
<ToastContainer autoClose={false} closeOnClick newestOnTop limit={5} theme={darkMode ? "dark" : "colored"} />
Example condition
At default, darkMode
is false, so the ToastContainer
is theme=colored
. A toast is created and will not auto close(For example, a "You Got A New Message" toast). Later, darkMode
is changed(by user or by system time), the created toast will not rerender itself to dark
like other component, it will keep as a colored
toast, only newly created toast will apply the new dark
value.
Does toastify
listen to theme
change and rerender the toast
? If not, will this feature be added?
I know there's a toast.update()
function that I can use, but that will require the darkMode
to be passed to every sub components(and their sub components too), and use it like
useEffect(()=>{toast.update(toastId, {theme: <THE CONDITION>})},[darkMode])