Exercise 2.11
This commit is contained in:
parent
13439e412f
commit
9bd291a245
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"persons":[
|
||||
{
|
||||
"name": "Arto Hellas",
|
||||
"number": "040-123456",
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"name": "Ada Lovelace",
|
||||
"number": "39-44-5323523",
|
||||
"id": 2
|
||||
},
|
||||
{
|
||||
"name": "Dan Abramov",
|
||||
"number": "12-43-234345",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"name": "Mary Poppendieck",
|
||||
"number": "39-23-6423122",
|
||||
"id": 4
|
||||
}
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,7 @@
|
|||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"axios": "^0.27.2",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-scripts": "5.0.1",
|
||||
|
@ -15,7 +16,8 @@
|
|||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
"eject": "react-scripts eject",
|
||||
"server": "json-server -p3001 --watch db.json"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
|
@ -34,5 +36,8 @@
|
|||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"json-server": "^0.17.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import axios from 'axios'
|
||||
|
||||
import Filter from './components/Filter'
|
||||
import Form from './components/Form'
|
||||
|
@ -6,12 +7,11 @@ import Numbers from './components/Numbers'
|
|||
|
||||
const App = () => {
|
||||
const [filter, setFilter] = useState('')
|
||||
const [persons, setPersons] = useState([
|
||||
{ name: 'Arto Hellas', number: '040-123456', id: 1 },
|
||||
{ name: 'Ada Lovelace', number: '39-44-5323523', id: 2 },
|
||||
{ name: 'Dan Abramov', number: '12-43-234345', id: 3 },
|
||||
{ name: 'Mary Poppendieck', number: '39-23-6423122', id: 4 }
|
||||
])
|
||||
const [persons, setPersons] = useState([])
|
||||
|
||||
useEffect(() => axios
|
||||
.get('http://localhost:3001/persons')
|
||||
.then(response => setPersons(response.data)), []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
|
||||
import App from './App';
|
||||
|
|
Loading…
Reference in New Issue