mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
fix popup::onReactClick params (#1348)
This commit is contained in:
parent
7c67088914
commit
f2454bf576
@ -18,7 +18,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
import * as React from 'react';
|
||||
import {useRef, useState, useEffect} from 'react';
|
||||
import {useRef, useState, useEffect, useCallback} from 'react';
|
||||
import * as PropTypes from 'prop-types';
|
||||
import useMapControl, {mapControlDefaultProps, mapControlPropTypes} from './use-map-control';
|
||||
|
||||
@ -146,7 +146,8 @@ function onClick(evt, {props, context}) {
|
||||
*/
|
||||
function Popup(props) {
|
||||
const contentRef = useRef(null);
|
||||
const {context, containerRef} = useMapControl({...props, onClick});
|
||||
const thisRef = useMapControl({...props, onClick});
|
||||
const {context, containerRef} = thisRef;
|
||||
const [, setLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@ -169,7 +170,9 @@ function Popup(props) {
|
||||
);
|
||||
|
||||
// If eventManager does not exist (using with static map), listen to React event
|
||||
const onReactClick = context.eventManager ? null : onClick;
|
||||
const onReactClick = useCallback(e => !context.eventManager && onClick(e, thisRef), [
|
||||
context.eventManager
|
||||
]);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user