Browse Source

array of strings

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

18
src/App.js

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

Loading…
Cancel
Save