From 35c778b64472ebffe3803bd51528334563862d65 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Thu, 19 Nov 2020 11:47:47 +0100 Subject: [PATCH] fix use-behavior bug --- src/mol-plugin-ui/hooks/use-behavior.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mol-plugin-ui/hooks/use-behavior.ts b/src/mol-plugin-ui/hooks/use-behavior.ts index 61263df55..7ba6aa432 100644 --- a/src/mol-plugin-ui/hooks/use-behavior.ts +++ b/src/mol-plugin-ui/hooks/use-behavior.ts @@ -19,7 +19,10 @@ export function useBehavior<T>(s: Behavior<T> | undefined): T | undefined { const [value, setValue] = useState(s?.value); useEffect(() => { - if (!s) return; + if (!s) { + if (value !== void 0) setValue(void 0); + return; + } let fst = true; const sub = s.subscribe((v) => { if (fst) { -- GitLab