Somewhere in the code lies a flaw if someone could spot it it I would appreciate help thank you.
Step 1. react form to add a record to the state containing two variables [email & name]
export const AddForm = (props) => {
const [ name, setName ] = useState('')
const [ email, setEmail ] = useState('');
return (
<div>
Name:
<input type="text"
id="name"
onChange={ (event)=> { setName(event.target.value) }} /><br />
Email:
<input type="email"
id="email"
onChange={ (event)=> { setEmail(event.target.value) }}/><br />
<button type="button"
onClick={ ()=> { props.doAdd(name,email) } } >Add</button>
</div>
)
}
Step 2. The execution of the doAdd() function inside the main app.js
const doAdd = (name,email) => {
var newData = '{"name":'+name+',"email":'+email+'}';
setAllVals([...allVals,newData]);
}
after entering values my array of objects does not perform properly. for example allVals[0].name = blank (it should be name1
)