I am trying to add meeting events using Google Calendar API. In that I want to update my email in below ela object using hooks I mean to say that I want to update my email [email protected] 'attendees': [ {'email': '[email protected]'},] every time I take input using given form.
function App() {
var ela={
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'}
]
}
const [formDB,setFormDB]=useState(ela);
const handleClick = (e) => {
e.preventDefault();
gapi.load('client:auth2', () => {
console.log('loaded client')
gapi.client.load('calendar', 'v3', () => console.log('bam!'))
gapi.auth2.getAuthInstance().signIn()
.then(() => {
// var event=formDB;
console.log(formDB);
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': formDB,
})
request.execute(formDB => {
console.log(formDB)
window.open(formDB.htmlLink)
})}
return (
<div className="App">
// I need to fix this onChange eventin following input. Everytime I am trying to change using below logic it's saying
<input
type="email"
name="formDB.attendees[0].email"
value={formDB.attendees[0].email}
onChange={e=>setFormDB({ ...formDB.attendees[0], email: e.target.value})} **fix this**
/>
<input type="submit" name="Confirm" />
</form>
</div>
);
}
