Last active
April 8, 2020 08:37
-
-
Save btodts/a92eba6b7c7aadc2a225d4b17a79cc53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { useSelector, useDispatch } from "react-redux"; | |
import { TOGGLE_DARKTHEME } from "./actions"; | |
const DarkThemeToggle = () => { | |
const darkThemeEnabled = useSelector((state) => state.preferences.darkThemeEnabled); | |
const dispatch = useDispatch(); | |
return ( | |
<p> | |
<input | |
type="checkbox" | |
checked={darkThemeEnabled} | |
onChange={() => dispatch({ type: TOGGLE_DARKTHEME })} | |
></input> | |
<span>Use Dark Theme</span> | |
</p> | |
); | |
}; | |
export default DarkThemeToggle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment