-
Notifications
You must be signed in to change notification settings - Fork 818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add domRendered callback to InfoWindow to rebind React Router, etc #202
Comments
which is the status of this ? |
What can I do to help? This is affecting me as I need to put a |
Unfortunately, I never had time to make a PR and I've since moved on from the project and I don't know that my solution is the best. Somewhere I started investigating the use of "Portals" but had to move on to other things. That said, I ended up with something like:
Wrap MyMapComponent in withRouter() HOC from
The change to google-maps-react
Here is that same method in current master sans callback: https://github.com/fullstackreact/google-maps-react/blob/master/src/components/InfoWindow.js#L96 Basically, once the dom is rendered inside the infowindow, I'm calling the provided callback I passed in via props. From here, I just find the target element and bind click handlers. Not ideal, but works. As far as Material-UI goes, the component just acts as a ship to wrap the new dom inside of the MUI theme provider for styling. If you do not need it, you can remove it.
That said, there might be a way to address this problem using "Portals" but I never dug that far into them. Either/or, I think you still would need a callback to wrap the dom. More information on portals: https://reactjs.org/docs/portals.html |
Any chance this problem gets resolved? I really need to use Link in InfoWindow. Thanks! |
Hey @blainegarrett, any chance to see the code above on a repo? I'm struggling to make the InfoWindow popup/modal available with a Route. It seems you have succeed? |
Is there still an activity here? I really need this to work but I can't figure it out... |
Use case: The contents of my InfoWindow are Material-UI components that contain Buttons that utilize React Router and ultimately show a dialog. Currently, the InfoWindow component renders the children as a string and set this to the content of the infoWindow.setContent(renderedString). As such all event bindings are lost.
After experimenting, it seems infoWindow.setContent() can also take a dom element. If InfoWindow.renderChildren() could conditionally pass the rendered dom to a callback to further process it, we'd have an edge to rebind clickhandlers, etc.
I have gotten this to work on an older fork of google-maps-react. I have only tested it with React Router 3 and component. I assume react's sythentic events need to rebound for more general use, but I didn't need this for my use case. I'll try to branch latest master and make a PR adding this functionality.
The text was updated successfully, but these errors were encountered: