diff --git a/README.md b/README.md index feb3d20..1ccd2e1 100644 --- a/README.md +++ b/README.md @@ -27,29 +27,56 @@ npm install react-switch ## Usage ```javascript -import React, { Component } from "react"; +import { useState } from "react"; import Switch from "react-switch"; - -class SwitchExample extends Component { - constructor() { - super(); - this.state = { checked: false }; - this.handleChange = this.handleChange.bind(this); - } - - handleChange(checked) { - this.setState({ checked }); - } - - render() { - return ( - - ); - } -} +import { FiSun, FiMoon } from "react-icons/fi"; + +const App = () => { + const [isDarkTheme, setIsDarkTheme] = useState(false); + + const toggleTheme = () => { + setIsDarkTheme(!isDarkTheme); + }; + + const styles = { + lightTheme: { + backgroundColor: "#fff", + color: "#333", + }, + darkTheme: { + backgroundColor: "#222", + color: "#fff", + }, + }; + + return ( +
+
+

{isDarkTheme ? "Dark Theme" : "Light Theme"}

+
+
+

This is a beautiful minimal theme toggle!

+ } + checkedIcon={} + height={24} + width={48} + className="switch" + /> +
+
+ ); +}; + +export default App; ``` ### What's the deal with the label tag?