Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
@bingo-developer

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;`

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp