react-toggle-dark-mode icon indicating copy to clipboard operation
react-toggle-dark-mode copied to clipboard

Doesnt retain the darkmode when refreshed

Open Jellyyjelly opened this issue 2 years ago • 0 comments

I am completely new to coding, and I can't seem to use the typescript and thus I am using the example.9913d620.js from https://react-toggle-dark-mode.netlify.app/

Is there a way to stop it from going back to light mode after refreshing the page?

I am also looking if I can instead assign its state according to the value of a checkbox because I cant seem to use this if I change the div id="root" into an input type="checkbox" id="root" ( and of course changing the code I have to darkmode to document.getElementById("root").checked )

I am using it like this:

<label tabindex="0" for="mode" >
	<input id="mode" type="checkbox">
	<div id="root">
	</div>
</label>

where my website switches to darkmode when I click the icon as it animates into a moon, and checks the checkbox id="mode". However, when i refresh the page, it stays in darkmode, but the icon goes back to a sun. If you also check the https://react-toggle-dark-mode.netlify.app/ if you turn it into dark mode and then refresh the page, it goes back to light mode.

I want it to retain, how can I do it?

Thank you so much in advance

Jellyyjelly avatar Sep 05 '23 09:09 Jellyyjelly