()
| 2 | import List from './List'; |
| 3 | import Alert from './Alert'; |
| 4 | const getLocalStorage = () => { |
| 5 | let list = localStorage.getItem('list'); |
| 6 | if (list) { |
| 7 | return (list = JSON.parse(localStorage.getItem('list'))); |
| 8 | } else { |
| 9 | return []; |
| 10 | } |
| 11 | }; |
| 12 | function App() { |
| 13 | const [name, setName] = useState(''); |
| 14 | const [list, setList] = useState(getLocalStorage()); |