Skip to content

Commit

Permalink
fixes useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley14 committed Sep 13, 2023
1 parent ef0a548 commit ce8ae6a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,22 @@ export const QueryBar = memo<QueryBarComponentProps>(
);

useEffect(() => {
let dv: DataView;
if (isDataView(indexPattern)) {
setDataView(indexPattern);
} else {
const createDataView = async () => {
const dv = await data.dataViews.create({ title: indexPattern.title });
dv = await data.dataViews.create({ title: indexPattern.title });
setDataView(dv);
};
createDataView();
}
return () => {
if (dataView?.id) {
data.dataViews.clearInstanceCache(dataView?.id);
if (dv?.id) {
data.dataViews.clearInstanceCache(dv?.id);
}
};
}, [data.dataViews, dataView?.id, indexPattern]);
}, [data.dataViews, indexPattern]);

const timeHistory = useMemo(() => new TimeHistory(new Storage(localStorage)), []);
const arrDataView = useMemo(() => (dataView != null ? [dataView] : []), [dataView]);
Expand Down

0 comments on commit ce8ae6a

Please sign in to comment.