Skip to content

Instantly share code, notes, and snippets.

@Kellswork
Created September 29, 2021 22:19
Show Gist options
  • Save Kellswork/b307034986c9a3dc923182b3896773e4 to your computer and use it in GitHub Desktop.
Save Kellswork/b307034986c9a3dc923182b3896773e4 to your computer and use it in GitHub Desktop.
Display Form Data in Another Component
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