Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Dark/Light theme rendering issue Blazor .NET8

$
0
0

I'm trying to add a class 'dark' if it is in localstorage, and remove it if there is 'light' as 'mode' in localstorage.However, I have the feeling that all pages of my blazor .NET8 application are cached. It saves the mode in local storage, but when I switch pages it doesn't execute the javascript 'onload' statement. Only if I then manually refresh the page again.

I'm curious, does Blazor cache all the pages, because it doesn't re-render the page when you go to it. Does this have to do with a specific rendermode in Blazor?

What I've tried is using the 'onload' param in the body tag. However the onload statement is'nt executed when rendering the page.

<body onload="localStorage.getItem('mode') === 'dark' ? document.querySelector('body').classList.add('dark') : document.querySelector('body').classList.remove('dark')">


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>