Skip to content
60 changes: 27 additions & 33 deletions lib/components/OverlayView.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) {
var mapPanes = this.state[_constants.OVERLAY_VIEW].getPanes()
mapPanes[mapPaneName].appendChild(this.containerElement)

_reactDom2.default.unstable_renderSubtreeIntoContainer(
this,
_react2.default.Children.only(this.props.children),
this.containerElement,
this.onPositionElement
)
if (_react2.default.version.match(/^16/)) {
this.onPositionElement()
this.forceUpdate()
} else {
_reactDom2.default.unstable_renderSubtreeIntoContainer(
this,
_react2.default.Children.only(this.props.children),
this.containerElement,
this.onPositionElement
)
}
},
},
{
Expand Down Expand Up @@ -181,8 +186,12 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) {
{
key: "onRemove",
value: function onRemove() {
this.containerElement.parentNode.removeChild(this.containerElement)
_reactDom2.default.unmountComponentAtNode(this.containerElement)
if (this.containerElement) {
this.containerElement.parentNode.removeChild(this.containerElement)
}
if (!_react2.default.version.match(/^16/)) {
_reactDom2.default.unmountComponentAtNode(this.containerElement)
}
this.containerElement = null
},
},
Expand All @@ -206,7 +215,10 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) {
updaterMap,
prevProps
)
;(0, _delay3.default)(this.state[_constants.OVERLAY_VIEW].draw)

if (!_react2.default.version.match(/^16/)) {
;(0, _delay3.default)(this.state[_constants.OVERLAY_VIEW].draw)
}
},
},
{
Expand All @@ -226,32 +238,14 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) {
{
key: "render",
value: function render() {
if (_react2.default.version.match(/^16/) && this.containerElement) {
return _reactDom2.default.createPortal(
_react2.default.Children.only(this.props.children),
this.containerElement
)
}
return false
},

/**
* Returns the panes in which this OverlayView can be rendered. The panes are not initialized until `onAdd` is called by the API.
* @type MapPanesonAdd
* @public
*/
},
{
key: "getPanes",
value: function getPanes() {
return this.state[_constants.OVERLAY_VIEW].getPanes()
},

/**
* Returns the `MapCanvasProjection` object associated with this `OverlayView`. The projection is not initialized until `onAdd` is called by the API.
* @type MapCanvasProjectionMapCanvasProjectionOverlayViewonAdd
* @public
*/
},
{
key: "getProjection",
value: function getProjection() {
return this.state[_constants.OVERLAY_VIEW].getProjection()
},
},
])
return OverlayView
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-google-maps",
"version": "9.4.5",
"name": "react-google-maps-tmp",
"version": "9.4.9",
"description": "React.js Google Maps integration component",
"license": "MIT",
"author": {
Expand Down
54 changes: 27 additions & 27 deletions src/components/OverlayView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,17 @@ export class OverlayView extends React.PureComponent {
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
)
if (React.version.match(/^16/)) {
this.onPositionElement()
this.forceUpdate()
} else {
ReactDOM.unstable_renderSubtreeIntoContainer(
this,
React.Children.only(this.props.children),
this.containerElement,
this.onPositionElement
)
}
}

onPositionElement() {
Expand All @@ -126,8 +131,12 @@ export class OverlayView extends React.PureComponent {
}

onRemove() {
this.containerElement.parentNode.removeChild(this.containerElement)
ReactDOM.unmountComponentAtNode(this.containerElement)
if (this.containerElement) {
this.containerElement.parentNode.removeChild(this.containerElement)
}
if (!React.version.match(/^16/)) {
ReactDOM.unmountComponentAtNode(this.containerElement)
}
this.containerElement = null
}

Expand All @@ -143,7 +152,10 @@ export class OverlayView extends React.PureComponent {
updaterMap,
prevProps
)
_.delay(this.state[OVERLAY_VIEW].draw)

if (!React.version.match(/^16/)) {
_.delay(this.state[OVERLAY_VIEW].draw)
}
}

componentWillUnmount() {
Expand All @@ -159,26 +171,14 @@ export class OverlayView extends React.PureComponent {
}

render() {
if (React.version.match(/^16/) && this.containerElement) {
return ReactDOM.createPortal(
React.Children.only(this.props.children),
this.containerElement
)
}
return false
}

/**
* Returns the panes in which this OverlayView can be rendered. The panes are not initialized until `onAdd` is called by the API.
* @type MapPanesonAdd
* @public
*/
getPanes() {
return this.state[OVERLAY_VIEW].getPanes()
}

/**
* Returns the `MapCanvasProjection` object associated with this `OverlayView`. The projection is not initialized until `onAdd` is called by the API.
* @type MapCanvasProjectionMapCanvasProjectionOverlayViewonAdd
* @public
*/
getProjection() {
return this.state[OVERLAY_VIEW].getProjection()
}
}

export default OverlayView
Expand Down
36 changes: 27 additions & 9 deletions src/macros/OverlayView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,17 @@ export class OverlayView extends React.PureComponent {
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
)
if (React.version.match(/^16/)) {
this.onPositionElement()
this.forceUpdate()
} else {
ReactDOM.unstable_renderSubtreeIntoContainer(
this,
React.Children.only(this.props.children),
this.containerElement,
this.onPositionElement
)
}
}

onPositionElement() {
Expand All @@ -123,8 +128,12 @@ export class OverlayView extends React.PureComponent {
}

onRemove() {
this.containerElement.parentNode.removeChild(this.containerElement)
ReactDOM.unmountComponentAtNode(this.containerElement)
if (this.containerElement) {
this.containerElement.parentNode.removeChild(this.containerElement)
}
if (!React.version.match(/^16/)) {
ReactDOM.unmountComponentAtNode(this.containerElement)
}
this.containerElement = null
}

Expand All @@ -140,7 +149,10 @@ export class OverlayView extends React.PureComponent {
updaterMap,
prevProps
)
_.delay(this.state[OVERLAY_VIEW].draw)

if (!React.version.match(/^16/)) {
_.delay(this.state[OVERLAY_VIEW].draw)
}
}

componentWillUnmount() {
Expand All @@ -156,6 +168,12 @@ export class OverlayView extends React.PureComponent {
}

render() {
if (React.version.match(/^16/) && this.containerElement) {
return ReactDOM.createPortal(
React.Children.only(this.props.children),
this.containerElement
)
}
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tx/ClassDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function contentToJS(KlassName, $, $content) {
const $constructorTable = $content.find(
`[summary="class ${KlassName} - Constructor"]`
)
const [, constructorArgs] = $constructorTable
const constructorArgs = $constructorTable
.find(`tr > td > code`)
.text()
.match(/\S+\((.*)\)/)
Expand Down