This file contains hidden or 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
| <input value={todo} onChange={(e) => setTodo(e.target.value)} /> |
This file contains hidden or 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
| const [todo, setTodo] = useState(""); |
This file contains hidden or 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
| const [todoList, setTodoList] = useRecoilState(todoListState); |
This file contains hidden or 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 { useRecoilValue, atom } from "recoil"; | |
| const todoListState = atom({ | |
| key: "todoListState", | |
| default: ["Apples", "Eggs", "Butter"], | |
| }); | |
| function App() { | |
| const todoList = useRecoilValue(todoListState); |
This file contains hidden or 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 { useRecoilValue, atom } from "recoil"; | |
| const todoListState = atom({ | |
| key: 'todoListState', | |
| default: ['Apples', 'Eggs', 'Butter'], | |
| }); |
This file contains hidden or 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 ReactDOM from "react-dom"; | |
| import "./index.css"; | |
| import App from "./App"; | |
| import * as serviceWorker from "./serviceWorker"; | |
| import { RecoilRoot } from "recoil"; | |
| ReactDOM.render( | |
| <React.StrictMode> | |
| <RecoilRoot> |
This file contains hidden or 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
| const fontSizeLabelState = selector({ | |
| key: 'fontSizeLabelState', | |
| get: ({get}) => { | |
| const fontSize = get(fontSizeState); | |
| const unit = 'px'; | |
| return `${fontSize}${unit}`; | |
| }, | |
| }); |
This file contains hidden or 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
| function Text() { | |
| const [fontSize, setFontSize] = useRecoilState(fontSizeState); | |
| return <p style={{fontSize}}>This text will increase in size too.</p>; | |
| } |