diff --git a/src/react/hooks.ts b/src/react/hooks.ts index f539ca5..7981771 100644 --- a/src/react/hooks.ts +++ b/src/react/hooks.ts @@ -163,11 +163,15 @@ export function useVariable( id: string, ): [WorkbookVariable | undefined, Function] { const client = usePlugin(); - const [workbookVariable, setWorkbookVariable] = useState( - client.config.getVariable(id), - ); + const [workbookVariable, setWorkbookVariable] = useState(); + + const isFirstRender = useRef(true); useEffect(() => { + if (isFirstRender.current) { + setWorkbookVariable(client.config.getVariable(id)); + isFirstRender.current = false; + } return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable); }, [client, id]);