[Canvas] Fixes Advanced settings in Datasource recreate on any change. (#111840)
* added useEffectOnce. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
dd3053d23e
commit
ec313f6373
|
@ -12,7 +12,9 @@ import { DatasourceComponent } from './datasource_component';
|
|||
|
||||
export const Datasource = (props) => {
|
||||
const { datasource, stateDatasource } = props;
|
||||
if (!datasource || !stateDatasource) return <NoDatasource {...props} />;
|
||||
if (!datasource || !stateDatasource) {
|
||||
return <NoDatasource {...props} />;
|
||||
}
|
||||
|
||||
return <DatasourceComponent {...props} />;
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import React, { useEffect, useRef, useCallback } from 'react';
|
||||
import useEffectOnce from 'react-use/lib/useEffectOnce';
|
||||
import { Ast } from '@kbn/interpreter/common';
|
||||
import { RenderToDom } from '../components/render_to_dom';
|
||||
import { BaseForm, BaseFormProps } from './base_form';
|
||||
|
@ -62,10 +63,11 @@ const DatasourceWrapper: React.FunctionComponent<DatasourceWrapperProps> = (prop
|
|||
|
||||
useEffect(() => {
|
||||
callRenderFn();
|
||||
return () => {
|
||||
handlers.destroy();
|
||||
};
|
||||
}, [callRenderFn, handlers, props]);
|
||||
}, [callRenderFn, props]);
|
||||
|
||||
useEffectOnce(() => () => {
|
||||
handlers.destroy();
|
||||
});
|
||||
|
||||
return (
|
||||
<RenderToDom
|
||||
|
|
Loading…
Reference in a new issue