Created
September 29, 2021 22:19
-
-
Save Kellswork/b307034986c9a3dc923182b3896773e4 to your computer and use it in GitHub Desktop.
Display Form Data in Another Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import ContactForm from "./components/ContactForm.jsx"; | |
import "./App.css"; | |
function App() { | |
// here we create an array state to store the contact form data | |
const [contacts, updateContacts] = useState([]); | |
const addContact = (contactInfo) => { | |
updateContacts([...contacts, contactInfo]); | |
}; | |
console.log(contacts) | |
return ( | |
<div className="App"> | |
<ContactForm addContact={addContact} /> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment