refactor: standardize quotation marks in pnpm-lock.yaml and improve code formatting across various components; enhance readability and maintain consistency in code style
This commit is contained in:
@@ -7,7 +7,7 @@ import { useState } from "react";
|
||||
*/
|
||||
export function useLocalStorage<T>(
|
||||
key: string,
|
||||
initialValue: T
|
||||
initialValue: T,
|
||||
): [T, (value: T | ((val: T) => T)) => void] {
|
||||
// État pour stocker la valeur
|
||||
const [storedValue, setStoredValue] = useState<T>(() => {
|
||||
@@ -29,9 +29,9 @@ export function useLocalStorage<T>(
|
||||
// Permet d'utiliser une fonction comme setState
|
||||
const valueToStore =
|
||||
value instanceof Function ? value(storedValue) : value;
|
||||
|
||||
|
||||
setStoredValue(valueToStore);
|
||||
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
||||
}
|
||||
@@ -42,4 +42,3 @@ export function useLocalStorage<T>(
|
||||
|
||||
return [storedValue, setValue];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user