mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(react): fix leak & adjustable class name
This commit is contained in:
parent
df3aa04787
commit
c33280bbb2
@ -414,8 +414,9 @@ export function useNoteBlob(note: FNote | null | undefined): [ FBlob | null | un
|
|||||||
return [ blob ] as const;
|
return [ blob ] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLegacyWidget(widgetFactory: () => BasicWidget, { noteContext }: {
|
export function useLegacyWidget(widgetFactory: () => BasicWidget, { noteContext, containerClassName }: {
|
||||||
noteContext?: NoteContext;
|
noteContext?: NoteContext;
|
||||||
|
containerClassName?: string;
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
@ -434,7 +435,7 @@ export function useLegacyWidget(widgetFactory: () => BasicWidget, { noteContext
|
|||||||
|
|
||||||
const renderedWidget = widget.render();
|
const renderedWidget = widget.render();
|
||||||
return [ widget, renderedWidget ];
|
return [ widget, renderedWidget ];
|
||||||
}, [widgetFactory]);
|
}, []);
|
||||||
|
|
||||||
// Attach the widget to the parent.
|
// Attach the widget to the parent.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -452,5 +453,5 @@ export function useLegacyWidget(widgetFactory: () => BasicWidget, { noteContext
|
|||||||
}
|
}
|
||||||
}, [ noteContext ]);
|
}, [ noteContext ]);
|
||||||
|
|
||||||
return <div ref={ref} />
|
return <div className={containerClassName} ref={ref} />
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user