mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
16 lines
405 B
JavaScript
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];
|
|
}
|