I've been trying to fix this issue but couldn't. I'm using use-dark-mode with gatsby and while developing the application it works fine, but when I run build of the application it shows wrong behaviour, On page refresh the icon changes from the previous value even though the mode (dark/light persists)

I've added the your custom js in my html but doesn't seem to work.
Here's my implimentation
export default function Navbar({ title }) {
const darkMode = useDarkMode()
return (
<nav className="nav">
<Container>
<div className="nav__content">
<Link to="/" className="nav__brand">
{darkMode.value ? "Dark" : "Light"}
</Link>
<div className="nav__right">
{darkMode.value === true ? (
<Sun disable={darkMode.disable} />
) : (
<Moon enable={darkMode.enable} />
)}
</div>
</div>
</Container>
</nav>
)
}
This is how I style elements
body.light-mode nav {
background: rgb(153, 153, 153);
color: black;
}
body.dark-mode nav {
background: $dark-mode-section;
}
Thanks for your help
I've been trying to fix this issue but couldn't. I'm using use-dark-mode with gatsby and while developing the application it works fine, but when I run build of the application it shows wrong behaviour, On page refresh the icon changes from the previous value even though the mode (dark/light persists)
I've added the your custom js in my html but doesn't seem to work.
Here's my implimentation
This is how I style elements
Thanks for your help