fix popup::onReactClick params (#1348)

This commit is contained in:
Arni Sumarlidason 2021-02-10 17:49:33 -05:00 committed by Xiaoji Chen
parent 7c67088914
commit f2454bf576

View File

@ -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