React lets you build user interfaces out of individual pieces called components. Create your own React components like Thumbnail, LikeButton, and Video. Then combine them into entire screens, pages, and apps.
How to reproduce it
export default function MainPage(): ReactElement {
...
if (settings.theme !== 2) {
updateSettings({ ...settings, theme: 2 });
}
...
}
Error
Cannot update a component (<ContextProvider>) while rendering a different component.
Solution
Wrap the setState call into the useEffect hook.
export default function MainPage(): ReactElement {
...
useEffect(() => {
if (settings.theme !== 2) {
updateSettings({ ...settings, theme: 2 });
}
}, []);
...
}