Skip to content

Commit

Permalink
Update OverlayView.jsx
Browse files Browse the repository at this point in the history
this way, I tried to fix the unsafe method, when I updated the coords the children got destroyed and created again.
  • Loading branch information
Infinity0106 authored Jan 12, 2019
1 parent ca5c5c6 commit ed1905a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/macros/OverlayView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,22 @@ export class OverlayView extends React.PureComponent {
onAdd() {
this.containerElement = document.createElement(`div`)
this.containerElement.style.position = `absolute`
}

draw() {
ReactDOM.render(this.props.children, this.containerElement)

const { mapPaneName } = this.props
invariant(
!!mapPaneName,
`OverlayView requires either props.mapPaneName or props.defaultMapPaneName but got %s`,
mapPaneName
)
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapPanes

const mapPanes = this.state[OVERLAY_VIEW].getPanes()
mapPanes[mapPaneName].appendChild(this.containerElement)
}

ReactDOM.unstable_renderSubtreeIntoContainer(
this,
React.Children.only(this.props.children),
this.containerElement,
this.onPositionElement
)
draw() {
this.onPositionElement()
}

onPositionElement() {
Expand Down

0 comments on commit ed1905a

Please sign in to comment.