Skip to content

Doesnt retain the darkmode when refreshed #44

@Jellyyjelly

Description

@Jellyyjelly

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions