import React from 'react'; import logo from './logo.svg'; import './App.css'; import produce from 'immer'; import { useState } from 'react'; /*const Notes = props => props.data.map(note =>
{note.text}
); const initialData = [{ text: 'Hey' }, { text: 'There' }]; const [data, setData] = useState(initialData); const handleClick = () => { const text = document.querySelector('#noteinput').value.trim(); if (text) { const nextState = produce(data, draftState => { draftState.push({ text }); }); document.querySelector('#noteinput').value = ''; setData(nextState); } }; return (
); }*/ function App() { const [input, setInput] = useState(""); const [list, setList] = useState([]); const [visible, setVisible] = useState(null); const addToList = e => { setList([ ...list, input ]); setInput(""); }; const deleteList = id => e => { setList(list.filter((item, index) => index !== id)); }; function hideMe(){ setVisible(false); } let style = { textDecoration: "none" }; if (!visible) style.textDecoration = "line-through"; return(
setInput(e.target.value)} />
); } export default App;