From fb305f4b78040471af2c21d232ff1212010c91ad Mon Sep 17 00:00:00 2001 From: Seongjun kim Date: Wed, 9 May 2018 12:30:58 -0400 Subject: [PATCH 1/8] fix mapPanes undefined and overlayTarget undefined --- src/components/OverlayView.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/OverlayView.jsx b/src/components/OverlayView.jsx index 4bbe0508..a1827db1 100644 --- a/src/components/OverlayView.jsx +++ b/src/components/OverlayView.jsx @@ -98,14 +98,16 @@ export class OverlayView extends React.PureComponent { ) // https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapPanes const mapPanes = this.state[OVERLAY_VIEW].getPanes() - mapPanes[mapPaneName].appendChild(this.containerElement) + if(mapPanes) { + mapPanes[mapPaneName].appendChild(this.containerElement) + ReactDOM.unstable_renderSubtreeIntoContainer( + this, + React.Children.only(this.props.children), + this.containerElement, + this.onPositionElement + ) + } - ReactDOM.unstable_renderSubtreeIntoContainer( - this, - React.Children.only(this.props.children), - this.containerElement, - this.onPositionElement - ) } onPositionElement() { From a6754cb59bc6e9d1f3a97aefd32377f100b97ee7 Mon Sep 17 00:00:00 2001 From: Uri Klar Date: Mon, 20 Aug 2018 14:57:35 +0300 Subject: [PATCH 2/8] fix(OverlayView): use `ReactDOM.createPortal` in React@^16 --- src/macros/OverlayView.jsx | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/macros/OverlayView.jsx b/src/macros/OverlayView.jsx index d0e6878a..bac84bca 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() { @@ -124,7 +129,9 @@ export class OverlayView extends React.PureComponent { onRemove() { this.containerElement.parentNode.removeChild(this.containerElement) - ReactDOM.unmountComponentAtNode(this.containerElement) + if (!React.version.match(/^16/)) { + ReactDOM.unmountComponentAtNode(this.containerElement) + } this.containerElement = null } @@ -140,7 +147,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 +166,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 } } From 278cf083434f9cd322b947ad19b6cac5496e3e9a Mon Sep 17 00:00:00 2001 From: Uri Klar Date: Mon, 20 Aug 2018 15:16:04 +0300 Subject: [PATCH 3/8] fix(tx): fix "destructure non-iterable instance" error on CI builds copied from PR: https://github.com/tomchentw/react-google-maps/pull/822 --- src/tx/ClassDefinition.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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+\((.*)\)/) From 13a5f8f484e2d2860df59efa1aa4ddabe79dddf3 Mon Sep 17 00:00:00 2001 From: Uri Klar Date: Mon, 20 Aug 2018 15:39:54 +0300 Subject: [PATCH 4/8] chore(src/components): compile OverlayView.jsx from src/macros with `babel` --- src/components/OverlayView.jsx | 50 ++++++++++++++++------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/components/OverlayView.jsx b/src/components/OverlayView.jsx index 4bbe0508..888f37cc 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() { @@ -127,7 +132,9 @@ export class OverlayView extends React.PureComponent { onRemove() { this.containerElement.parentNode.removeChild(this.containerElement) - ReactDOM.unmountComponentAtNode(this.containerElement) + if (!React.version.match(/^16/)) { + ReactDOM.unmountComponentAtNode(this.containerElement) + } this.containerElement = null } @@ -143,7 +150,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 +169,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 From 2abc83ae95f849a5bdf88f84e5de0f18a4a5d295 Mon Sep 17 00:00:00 2001 From: Uri Klar Date: Mon, 20 Aug 2018 15:40:33 +0300 Subject: [PATCH 5/8] chore(lib): compile OverlayView.js from src with 'babel' --- lib/components/OverlayView.js | 56 +++++++++++++++-------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/lib/components/OverlayView.js b/lib/components/OverlayView.js index 01b03dfa..c66bb1dc 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 + ) + } }, }, { @@ -182,7 +187,9 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) { key: "onRemove", value: function onRemove() { this.containerElement.parentNode.removeChild(this.containerElement) - _reactDom2.default.unmountComponentAtNode(this.containerElement) + if (!_react2.default.version.match(/^16/)) { + _reactDom2.default.unmountComponentAtNode(this.containerElement) + } this.containerElement = null }, }, @@ -206,7 +213,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 +236,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 From 41714ee6424a7a515174c5d0e1dbf4e8941b157c Mon Sep 17 00:00:00 2001 From: Uri Klar Date: Mon, 20 Aug 2018 21:37:11 +0300 Subject: [PATCH 6/8] fix(OverlayView) - Cannot read property 'parentNode' of undefined --- lib/components/OverlayView.js | 4 +++- src/components/OverlayView.jsx | 4 +++- src/macros/OverlayView.jsx | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/components/OverlayView.js b/lib/components/OverlayView.js index c66bb1dc..be47d297 100644 --- a/lib/components/OverlayView.js +++ b/lib/components/OverlayView.js @@ -186,7 +186,9 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) { { key: "onRemove", value: function onRemove() { - this.containerElement.parentNode.removeChild(this.containerElement) + if (this.containerElement) { + this.containerElement.parentNode.removeChild(this.containerElement) + } if (!_react2.default.version.match(/^16/)) { _reactDom2.default.unmountComponentAtNode(this.containerElement) } diff --git a/src/components/OverlayView.jsx b/src/components/OverlayView.jsx index 888f37cc..82442c36 100644 --- a/src/components/OverlayView.jsx +++ b/src/components/OverlayView.jsx @@ -131,7 +131,9 @@ export class OverlayView extends React.PureComponent { } onRemove() { - this.containerElement.parentNode.removeChild(this.containerElement) + if (this.containerElement) { + this.containerElement.parentNode.removeChild(this.containerElement) + } if (!React.version.match(/^16/)) { ReactDOM.unmountComponentAtNode(this.containerElement) } diff --git a/src/macros/OverlayView.jsx b/src/macros/OverlayView.jsx index bac84bca..944e69c8 100644 --- a/src/macros/OverlayView.jsx +++ b/src/macros/OverlayView.jsx @@ -128,7 +128,9 @@ export class OverlayView extends React.PureComponent { } onRemove() { - this.containerElement.parentNode.removeChild(this.containerElement) + if (this.containerElement) { + this.containerElement.parentNode.removeChild(this.containerElement) + } if (!React.version.match(/^16/)) { ReactDOM.unmountComponentAtNode(this.containerElement) } From 7bcd024ccf208dc36a3b409416e2aab7e090caaa Mon Sep 17 00:00:00 2001 From: Seongjun kim Date: Fri, 1 Feb 2019 15:05:03 -0500 Subject: [PATCH 7/8] new lib --- lib/components/OverlayView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/OverlayView.js b/lib/components/OverlayView.js index ca50860c..be47d297 100644 --- a/lib/components/OverlayView.js +++ b/lib/components/OverlayView.js @@ -134,6 +134,7 @@ var OverlayView = (exports.OverlayView = (function(_React$PureComponent) { key: "draw", value: function draw() { var mapPaneName = this.props.mapPaneName + ;(0, _invariant2.default)( !!mapPaneName, "OverlayView requires either props.mapPaneName or props.defaultMapPaneName but got %s", From 03c438afbd2ee47cd2525b8d557b18feebaeae94 Mon Sep 17 00:00:00 2001 From: Seongjun kim Date: Fri, 1 Feb 2019 15:06:48 -0500 Subject: [PATCH 8/8] version updated --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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": {