Skip to content

Commit

Permalink
fix(globe): fix globe hook dependencies (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwambach authored Oct 18, 2019
1 parent 24242e6 commit e6a9df4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/scripts/components/globes/globes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import React, {FunctionComponent, useState, useEffect} from 'react';
import React, {
FunctionComponent,
useState,
useEffect,
useCallback
} from 'react';
import {useSelector, useDispatch} from 'react-redux';

import {selectedLayersSelector} from '../../reducers/selected-layers';
Expand All @@ -18,9 +23,14 @@ const Globes: FunctionComponent = () => {
const [currentView, setCurrentView] = useState(globalGlobeView);
const [isMainActive, setIsMainActive] = useState(true);
const selectedLayers = useSelector(selectedLayersSelector);
const onChangeHandler = (view: GlobeView) => setCurrentView(view);
const onMoveEndHandler = (view: GlobeView) =>
dispatch(setGlobeViewAction(view));
const onChangeHandler = useCallback(
(view: GlobeView) => setCurrentView(view),
[]
);
const onMoveEndHandler = useCallback(
(view: GlobeView) => dispatch(setGlobeViewAction(view)),
[dispatch]
);

// apply changes in the app state view to our local view copy
// we don't use the app state view all the time to keep store updates low
Expand Down

0 comments on commit e6a9df4

Please sign in to comment.