Skip to content

Commit

Permalink
Fix props reference on viewport resize (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Feb 4, 2021
1 parent 4190b1c commit 14a1972
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/interactive-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ const InteractiveMap = forwardRef((props, ref) => {
viewportUpdateRequested = [viewState, interactionState, oldViewState];
return;
}
const {onViewStateChange, onViewportChange} = props;
const {onViewStateChange, onViewportChange} = thisRef.props;

if (onViewStateChange) {
onViewStateChange({viewState, interactionState, oldViewState});
Expand Down Expand Up @@ -347,15 +347,15 @@ const InteractiveMap = forwardRef((props, ref) => {
return;
}

const {onInteractionStateChange} = props;
const {onInteractionStateChange} = thisRef.props;
if (onInteractionStateChange) {
onInteractionStateChange(interactionState);
}
};

const updateControllerOpts = () => {
const opts = Object.assign({}, props, props.viewState, {
isInteractive: Boolean(props.onViewStateChange || props.onViewportChange),
const opts = Object.assign({}, thisRef.props, thisRef.props.viewState, {
isInteractive: Boolean(thisRef.props.onViewStateChange || thisRef.props.onViewportChange),
onViewportChange: handleViewportChange,
onStateChange: handleInteractionStateChange,
eventManager,
Expand All @@ -370,7 +370,7 @@ const InteractiveMap = forwardRef((props, ref) => {
thisRef.width = width;
thisRef.height = height;
updateControllerOpts();
props.onResize({width, height});
thisRef.props.onResize({width, height});
};

useEffect(() => {
Expand Down

0 comments on commit 14a1972

Please sign in to comment.