-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
42 lines (37 loc) · 1.29 KB
/
App.js
File metadata and controls
42 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { useState } from 'react';
import ContactList from './components/ContactList';
import ContactForm from './components/ContactForm';
import './App.css';
function App() {
const [refreshKey, setRefreshKey] = useState(0);
const [currentContact, setCurrentContact] = useState(null);
const handleContactAddedOrUpdated = () => {
setRefreshKey(prevKey => prevKey + 1);
setCurrentContact(null); // Clear the form after an operation
};
const handleContactSelected = (contact) => {
setCurrentContact(contact);
};
return (
<div className="App">
<header className="App-header">
<h1>Contact Management System</h1>
</header>
<main>
<div className="content-section">
<ContactForm
currentContact={currentContact}
onContactAddedOrUpdated={handleContactAddedOrUpdated}
/>
</div>
<div className="content-section">
<ContactList
onContactSelected={handleContactSelected}
refreshKey={refreshKey}
/>
</div>
</main>
</div>
);
}
export default App;