Skip to content

Commit

Permalink
data percistance using localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
iamangelmp committed Mar 15, 2023
1 parent 6d70de6 commit 0bef93a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { useState } from "react";
import { useState, useEffect } from "react";
import Header from "./components/Header";
import Form from "./components/Form";
import PatienrsList from "./components/PatienrsList";

function App() {
const [patients, setPatients] = useState([]);
const [patients, setPatients] = useState(JSON.parse(localStorage.getItem('pacientes')) ?? []);
const [patient, setPatient] = useState({});

useEffect(()=>{
localStorage.setItem('pacientes',JSON.stringify(patients))
},[patients])

const deletePatient = (id) => {
const updatedPatients = patients.filter((patient) => patient.id !== id);
setPatients(updatedPatients);
Expand Down

1 comment on commit 0bef93a

@vercel
Copy link

@vercel vercel bot commented on 0bef93a Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.