You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

5 years ago
import React from 'react';
import logo from './logo.svg';
import './App.css';
import produce from 'immer';
import { useState } from 'react';
function App() {
5 years ago
/*const Notes = props => props.data.map(note => <div>{note.text}</div>);
5 years ago
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 (
<div className="App">
<input id="noteinput" style={{ width: '80%' }} type="text" placeholder="Enter a new note" />
<button onClick={() => handleClick()}>Add note</button>
<Notes data={data} />
</div>
);
5 years ago
}*/
5 years ago
5 years ago
const [fName, setfName] = useState('');
const submitValue = () => {
const frmdetails = {
'First Name' : fName
}
console.log(frmdetails);
};
return(
<div className="App">
<input type="text" placeholder="First Name" onChange={e => setfName(e.target.value)} />
<button onClick={()=>submitValue()}>Add note</button>
</div>
);
}
5 years ago
export default App;