fullstack_open/part2/phonebook/src/App.js

27 lines
689 B
JavaScript
Raw Normal View History

2022-06-15 12:06:09 -04:00
import { useState, useEffect } from 'react'
import axios from 'axios'
2022-06-14 09:15:34 -04:00
import Filter from './components/Filter'
import Form from './components/Form'
import Numbers from './components/Numbers'
const App = () => {
const [filter, setFilter] = useState('')
2022-06-15 12:06:09 -04:00
const [persons, setPersons] = useState([])
useEffect(() => axios
.get('http://localhost:3001/persons')
.then(response => setPersons(response.data)), []);
2022-06-14 09:15:34 -04:00
return (
<div>
<h1>Phonebook</h1>
<Filter filter={filter} setFilter={setFilter} />
<Form persons={persons} setPersons={setPersons} />
<Numbers persons={persons} filter={filter.toLowerCase()} />
</div>
)
}
export default App