complete 2.11

This commit is contained in:
counterweight 2025-05-25 14:26:09 +02:00
parent 949fef7a08
commit fee3e03818
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
5 changed files with 771 additions and 5 deletions

View file

@ -1,4 +1,6 @@
import { useState } from "react";
import { useState, useEffect } from "react";
import axios from "axios";
import PersonList from "./components/PersonList";
const SearchArea = ({ onChangeHandler }) => {
@ -34,13 +36,18 @@ const AddPersonForm = ({
};
const App = () => {
const [persons, setPersons] = useState([
{ name: "Arto Hellas", number: 123 },
]);
const [persons, setPersons] = useState([]);
const [searchString, setSearchString] = useState("");
const [newName, setNewName] = useState("");
const [newNumber, setNewNumber] = useState("");
useEffect(() => {
axios.get("http://localhost:3001/persons").then((response) => {
console.log(response.data);
setPersons(response.data);
});
}, []);
const handleOnSubmit = (event) => {
event.preventDefault();
if (