我想:如何调用函数getCenter()和其他反应 - 谷歌 - 地图
<GoogleMap
defaultZoom={14}
center={{lat: props.mapCenter.lat, lng: props.mapCenter.lng}}
onCenterChanged={getCenter()}
/>
更新:我使用的是Stateless Functional Component
:
const MarkerClustererExampleGoogleMap = withGoogleMap(props => (
<GoogleMap
defaultZoom={14}
center={{lat: props.mapCenter.lat, lng: props.mapCenter.lng}}
onCenterChanged={getCenter()}
>
)
但我得到的错误:
getCenter is undefined.
如何解决此问题,谢谢。
哦,我可以用喜欢你的决心,但我有无国籍的组成部分。而我的变量“this”没有定义。我用部件使用GoogleMap不变量 “这个” '常量MarkerClustererExampleGoogleMap = withGoogleMap(道具=>( –
@ cm-brain检查更新后的答案,如何在无状态功能组件中定义函数,写入方式与其工作方式相同。 –