Skip to content

Instantly share code, notes, and snippets.

@mambodin mambodin/NoteApp V1

Created Jul 11, 2020
Embed
What would you like to do?
import React, {useState, useEffect} from 'react';
const NoteApp = () =>{
let [title, setTitle] = useState('')
let [noteBody, setNoteBody] = useState('')
let [notes, setNotes] = useState([])
let addNoteHandler = (e) =>{
e.preventDefault()
// console.log("FORM SUBMITTED")
setNotes([
...notes,
{
title,
noteBody,
}
])
setNoteBody('')
setTitle('')
}
let inputHandler = (e) =>{
setTitle(e.target.value)
// console.log(title)
}
let textAreaHandler = (e) =>{
setNoteBody(e.target.value)
}
useEffect(()=>{
console.log(notes)
})
return (
<div>
<h1>My Note App</h1>
<h3>Add Notes</h3>
<form onSubmit={addNoteHandler}>
<label>Note Title: </label>
<input value={title} onChange={inputHandler}></input>
<label>Notes: </label>
<textarea value={noteBody} onChange={textAreaHandler}></textarea>
<button>Submit</button>
</form>
</div>
)
}
export default NoteApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.