fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.3k stars 676 forks source link

Does ToastContainer listen to theme props and auto rerender? #1100

Open JobberRT opened 2 months ago

JobberRT commented 2 months ago

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?

JobberRT commented 2 months ago

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])