mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-25 16:02:50 +00:00
Fix props reference on viewport resize (#1328)
This commit is contained in:
parent
4190b1c602
commit
14a19722ea
@ -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});
|
||||
@ -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,
|
||||
@ -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(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user