Skip to content

Commit

Permalink
[fix] localStorage is not defined console error
Browse files Browse the repository at this point in the history
Next.js causing errors in the console...
TODO : Define the type of `rapportStorage` correctly so that TS don't do warning every lines...
  • Loading branch information
Azecko committed Nov 12, 2024
1 parent 6c5dc00 commit 96be676
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/responsable/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import EtatDeVaudSignature from "../components/EtatDeVaudSignature";

export default function Page() {
const inputFile = React.useRef<HTMLInputElement | null>(null);
var rapportStorage = JSON.parse(localStorage.getItem('rapport-de-stage') || '{}')
const [rapportStorage, setRapportStorage] = React.useState({});

React.useEffect(() => {
const storedData = localStorage.getItem('rapport-de-stage');
if (storedData) {
setRapportStorage(JSON.parse(storedData));
}
}, []);

const handleFileUpload = e => {
const confirm = window.confirm('Voulez-vous vraiment importer les données de ce fichier ?')
Expand Down

0 comments on commit 96be676

Please sign in to comment.