Files
traque/traque-front/hook/useLocalVariable.jsx
2025-09-04 14:18:01 +02:00

16 lines
405 B
JavaScript

import { useState, useEffect } from "react";
export default function useLocalVariable(variable, setVariable) {
const [localVariable, setLocalVariable] = useState(variable);
useEffect(() => {
setLocalVariable(variable);
}, [variable]);
function applyLocalVariable() {
setVariable(localVariable);
}
return [localVariable, setLocalVariable, applyLocalVariable];
}