If a user tries to set their name to I'm dangerous!, React encodes characters like < into <. React protects us from this by default, by sanitising the contents before rendering it.
#Perfect dark pc save code
Usually, setting HTML from code is risky business because it is easy to inadvertently expose users to a cross-site scripting (XSS) attack. The browser DOM provides us with innerHTML to get or set the HTML contained within an element. This means that until all this has been done, our user still sees only what the HTML has described: a transparent background. If there's any preference for dark mode that has been stored (usually using local storage), it's also loaded by the JS. The JS loaded first needs to be parsed before it starts to "hydrate" the page.The HTML can contain inline CSS to set the background color so that we don't see the "flicker" but currently, inline CSS doesn't support media queries so we can't find out if the user even prefers dark mode.By default, a webpage has a transparent background color, which means that you'll get a white background unless you're using certain extensions.The HTML gets loaded first, which in turn loads the JS and CSS.This is because when our page loads up, here's that happens: This is a problem that is not limited to static/hybrid websites but extends to pretty much any website that uses JavaScript to "hydrate" its components. MDXJS' website flicker before toggling dark mode on refresh If you take a look at a website which has support for dark mode like, you'll notice something if you try to refresh the page once you've enabled dark mode.
![perfect dark pc save perfect dark pc save](https://www.covercentury.com/covers/pc/d/dungeons_and_dragons_dragonshard_-_pc_games_cdd.jpg)
So what's the big deal? What really is the perfect dark mode?