Skip to content

Commit

Permalink
Update new useEffect hooks that are missing dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Dec 19, 2019
1 parent 8d8acce commit 0a10def
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ const EmbeddedPanel = styled.div`

export const EmbeddedMap = ({ upPoints, downPoints }: EmbeddedMapProps) => {
const [embeddable, setEmbeddable] = useState<MapEmbeddable>();
const embeddableRoot: React.RefObject<HTMLDivElement> = React.createRef();
const factory = start.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);

const input = {
id: uuid.v4(),
filters: [],
hidePanelTitles: true,
query: { query: '', language: 'kuery' },
refreshConfig: { value: 0, pause: false },
viewMode: 'view',
isLayerTOCOpen: false,
hideFilterActions: true,
mapCenter: { lon: 11, lat: 47, zoom: 0 },
disableInteractive: true,
disableTooltipControl: true,
hideToolbarOverlay: true,
};

useEffect(() => {
async function setupEmbeddable() {
Expand All @@ -59,38 +76,19 @@ export const EmbeddedMap = ({ upPoints, downPoints }: EmbeddedMapProps) => {
setEmbeddable(embeddableObject);
}
setupEmbeddable();
}, []);
}, [downPoints, factory, input, upPoints]);

useEffect(() => {
if (embeddable) {
embeddable.setLayerList(getLayerList(upPoints, downPoints));
}
}, [upPoints, downPoints]);
}, [embeddable, upPoints, downPoints]);

useEffect(() => {
if (embeddableRoot.current && embeddable) {
embeddable.render(embeddableRoot.current);
}
}, [embeddable]);

const factory = start.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);

const input = {
id: uuid.v4(),
filters: [],
hidePanelTitles: true,
query: { query: '', language: 'kuery' },
refreshConfig: { value: 0, pause: false },
viewMode: 'view',
isLayerTOCOpen: false,
hideFilterActions: true,
mapCenter: { lon: 11, lat: 47, zoom: 0 },
disableInteractive: true,
disableTooltipControl: true,
hideToolbarOverlay: true,
};

const embeddableRoot: React.RefObject<HTMLDivElement> = React.createRef();
}, [embeddable, embeddableRoot]);

return (
<EmbeddedPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ export function MonitorListDrawerComponent({
loadMonitorDetails,
monitorDetails,
}: MonitorListDrawerProps) {
const monitorId = summary?.monitor_id;
useEffect(() => {
if (monitorId) {
loadMonitorDetails(monitorId);
}
}, [loadMonitorDetails, monitorId]);

if (!summary || !summary.state.checks) {
return null;
}
useEffect(() => {
loadMonitorDetails(summary.monitor_id);
}, []);

const monitorUrl: string | undefined = get(summary.state.url, 'full', undefined);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const MonitorStatusDetailsComponent = ({
}: MonitorStatusBarProps) => {
useEffect(() => {
loadMonitorLocations(monitorId);
}, [monitorId, dateStart, dateEnd]);
}, [loadMonitorLocations, monitorId, dateStart, dateEnd]);

return (
<EuiPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const Container: React.FC<Props> = ({
}: Props) => {
useEffect(() => {
loadSnapshotCount(dateRangeStart, dateRangeEnd, filters, statusFilter);
}, [dateRangeStart, dateRangeEnd, filters, lastRefresh, statusFilter]);
}, [dateRangeStart, dateRangeEnd, filters, lastRefresh, loadSnapshotCount, statusFilter]);
return <PresentationalComponent count={count} height={height} loading={loading} />;
};

Expand Down

0 comments on commit 0a10def

Please sign in to comment.