Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const containerRef = useRef<HTMLDivElement | null>(null);
- const TestFunc = useCallback(()=>{
- /*
- whenever deps are chaging, a new instance of TestFunc is generating, which is triggering the use Effect mentioned below, and the new instance is getting appened to the existing subscribed events handlers
- */
- },[...deps])
- useEffect(() => {
- if (widget) {
- widget.destroy();
- widget.initialize();
- widget.on('beforequery', TestFunc)
- widget?.on('beforeload', () => {
- widgetObject.$$model.$$events.beforequery.handlers = [];
- });
- widget.container = containerRef.current;
- widget.refresh();
- }
- }, [widget, TestFunc]);
- return widget ? (
- <div
- data-testid='test-id'
- id='widgetContainerId'
- ref={containerRef}
- />
- ) : null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement