We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d42faf9 commit 1b83221Copy full SHA for 1b83221
src/react/hooks.ts
@@ -163,11 +163,15 @@ export function useVariable(
163
id: string,
164
): [WorkbookVariable | undefined, Function] {
165
const client = usePlugin();
166
- const [workbookVariable, setWorkbookVariable] = useState<WorkbookVariable>(
167
- client.config.getVariable(id),
168
- );
+ const [workbookVariable, setWorkbookVariable] = useState<WorkbookVariable>();
+
+ const isFirstRender = useRef<boolean>(true);
169
170
useEffect(() => {
171
+ if (isFirstRender.current) {
172
+ setWorkbookVariable(client.config.getVariable(id));
173
+ isFirstRender.current = false;
174
+ }
175
return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);
176
}, [client, id]);
177
0 commit comments