T
TanStack2y ago
correct-apricot

setState

Warning: Cannot update a component (ChatNotificationsProvider) while rendering a different component (Navbar). To locate the bad setState() call inside Navbar and the same goes to the NotificationsProvider when i try to set state to the context and i dont understand how to prevent this error
No description
4 Replies
inland-turquoise
inland-turquoise2y ago
Don’t use setState inside render
correct-apricot
correct-apricotOP2y ago
so how can i assign notifications to my context if i dont use setState
inland-turquoise
inland-turquoise2y ago
I think your architecture is skewed. A custom context for notifications is a red flag to me. To answer your question: useEffect
correct-apricot
correct-apricotOP2y ago
lol chill bro im still learning how can i handle notifications if not using context from react? i know there is zustand or sth like that i need to have them stored somewhere

Did you find this page helpful?