Browse Source

array of strings

master
rosh 4 years ago
parent
commit
47976dbe89
  1. 22
      src/App.js

22
src/App.js

@ -28,19 +28,21 @@ function App() {
); );
}*/ }*/
const [fName, setfName] = useState(''); const [input, setInput] = useState("");
const [list, setList] = useState([]);
const submitValue = () => { const addToList = e => {
const frmdetails = { setList([ ...list, input ]);
'First Name' : fName setInput("");
} };
console.log(frmdetails);
};
return( return(
<div className="App"> <div className="App">
<input type="text" placeholder="First Name" onChange={e => setfName(e.target.value)} /> <input type="text" placeholder="First Name" onChange={e => setInput(e.target.value)} />
<button onClick={()=>submitValue()}>Add note</button> <button type="button" onClick={addToList}>Submit</button>
</div> <ul>
{list.map(item => <li key={item}>{item}</li>)}
</ul>
</div>
); );
} }

Loading…
Cancel
Save