Skip to content

When I use react-activation, referencing the google-map-react component causes the parent component to re-render #1249

Description

@bingo-developer

`import React, { useEffect, useRef, useState } from "react";
import { Slider } from "antd";
import GoogleMapReact from 'google-map-react';

// const AnyReactComponent = ({ text }: { text: string, lat: number, lng: number }) => (
// <div style={{ width: '100px', background: '#fff' }}>{text}
// );

const MapContent = React.memo((props) => {
return (
<GoogleMapReact
bootstrapURLKeys={{ key: "" }}
center={{
lat: 28.19409,
lng: 112.982279
}}
zoom={3}
// onGoogleApiLoaded={onGoogleApiLoaded}
yesIWantToUseGoogleMapApiInternals
{...props}
>

)
})

const Map: React.FC = React.memo((props) => {
const mapRef = useRef(null);
const [zoom, setZoom] = useState(3);

const onGoogleApiLoaded = ({ map, maps }: { map: any, maps: any }) => {
console.log('reason?')
if (mapRef.current) return;
mapRef.current = map;
};
useEffect(() => {
console.log('render');
});
return (


<Slider value={zoom} min={3} max={16} onChange={(val) => setZoom(val)} />
<div style={{ height: '600px', width: '100%', position: 'relative' }}>

<div style={{ backdropFilter: 'blur(8px)', width: 100, height: 100, background: 'rgba(255, 255, 255, .05)', position: 'absolute', top: 50, left: 50 }}>



)
})

export default Map;`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions