Skip to content

Commit

Permalink
remove useRef
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Jun 7, 2024
1 parent 6b778be commit 7ac58cf
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions public/hooks/use_patch_fixed_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ISidecarConfig, SIDECAR_DOCKED_MODE } from '../../../../src/core/public
export const usePatchFixedStyle = () => {
const core = useCore();
const sidecarConfig$ = core.overlays.sidecar().getSidecarConfig$();
const textRef = useRef<Text>();

useEffect(() => {
const css = '';
Expand All @@ -23,18 +22,14 @@ export const usePatchFixedStyle = () => {
document.head.appendChild(style);
style.appendChild(text);

textRef.current = text;

const subscription = sidecarConfig$.subscribe((config) => {
if (!config) return;
updateHeadStyle(config, textRef.current);
updateHeadStyle(config, text);
});
return () => {
subscription.unsubscribe();
document.head.removeChild(style);
if (textRef.current) {
style.removeChild(textRef.current);
}
style.removeChild(text);
};
}, [sidecarConfig$]);
};
Expand Down

0 comments on commit 7ac58cf

Please sign in to comment.