diff --git a/lib/components/OverlayView.js b/lib/components/OverlayView.js index 01b03dfa..be47d297 100644 --- a/lib/components/OverlayView.js +++ b/lib/components/OverlayView.js @@ -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 + ) + } }, }, { @@ -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 }, }, @@ -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) + } }, }, { @@ -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 diff --git a/package.json b/package.json index e3d34ff9..67876bf1 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/components/OverlayView.jsx b/src/components/OverlayView.jsx index 4bbe0508..82442c36 100644 --- a/src/components/OverlayView.jsx +++ b/src/components/OverlayView.jsx @@ -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() { @@ -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 } @@ -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() { @@ -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 diff --git a/src/macros/OverlayView.jsx b/src/macros/OverlayView.jsx index d0e6878a..944e69c8 100644 --- a/src/macros/OverlayView.jsx +++ b/src/macros/OverlayView.jsx @@ -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() { @@ -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 } @@ -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() { @@ -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 } } diff --git a/src/tx/ClassDefinition.js b/src/tx/ClassDefinition.js index 705c8fa9..ec8edb3f 100644 --- a/src/tx/ClassDefinition.js +++ b/src/tx/ClassDefinition.js @@ -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+\((.*)\)/)