react-google-maps-api
react-google-maps-api copied to clipboard
onCloseClick not fired on InfoBoxComponent
InfoBox OnCloseClick stopped working when version updated from ^2.7.0 to 2.12.0
I was able to make it work. Adding this here so that if anybody else faces the issue can be helped.
os: mac node version 12.22.7 react version 16.13.1 @babel version ^7.12.1
@react-google-maps/api version
Q) How does it behave? A) I tried all possibilities to make onCloseClick work using 1. onCloseClick listener 2. using onLoad to add these properties i.e. infoBox.closeListener, infobox.addClickHandler() and verified using infoBox.getCloseClickHandler()
Solution
The only way for me to fix this issue was by downgrading to version "2.7.0"
@Saad-Khurshid use InfoBoxF instead
@Saad-Khurshid use InfoBoxF instead
It doesn't help
https://codesandbox.io/s/interesting-hill-09v5m5?file=/src/App.js
@aso1datov
use this in you package.json
"@react-google-maps/api": "2.7.0",
and then use it like below
{infoWindow && <InfoBox onCloseClick={() => setInfoWindow(null)} > </InfoBox>
@JustFly1984 I can not give this a try at this time.
@aso1datov use this in you package.json
"@react-google-maps/api": "2.7.0",
and then use it like below{infoWindow && <InfoBox onCloseClick={() => setInfoWindow(null)} > </InfoBox>
I use a different approach:
const infoBoxOptions = {
position,
disableAutoPan: true,
isHidden: !showInfoBox,
visible: showInfoBox,
}
return (
<InfoBoxF options={infoBoxOptions}>
// my content with custom close button
</InfoBoxF>
)
The issue is still present in Dec 2023. InfoBoxF
and InfoBox
still can't close with the close button.