react-google-maps
Advanced tools
Comparing version 4.4.1 to 4.5.0
@@ -0,1 +1,51 @@ | ||
<a name="4.5.0"></a> | ||
# [4.5.0](https://github.com/tomchentw/react-google-maps/compare/v4.4.1...v4.5.0) (2015-11-21) | ||
### Features | ||
* **async/ScriptjsLoader:** replacement of async/ScriptjsGoogleMap ([ccfadd4](https://github.com/tomchentw/react-google-maps/commit/ccfadd4)), closes [#145](https://github.com/tomchentw/react-google-maps/issues/145) | ||
### BREAKING CHANGES | ||
* async/ScriptjsLoader: migrate from async/ScriptjsGoogleMap to async/ScriptjsLoader and changed its behavior from implicit inheritance to simple delegation | ||
To migrate the code follow the example below (extracted from examples/gh-pages migration): | ||
Before: | ||
```js | ||
<ScriptjsLoader | ||
hostname={"maps.googleapis.com"} | ||
pathname={"/maps/api/js"} | ||
query={{v: `3.exp`, libraries: "geometry,drawing,places"}} | ||
// | ||
// <GoogleMap> props | ||
defaultZoom={3} | ||
defaultCenter={{lat: -25.363882, lng: 131.044922}} | ||
onClick={::this._handle_map_click} | ||
/> | ||
``` | ||
After: | ||
```js | ||
<ScriptjsLoader | ||
hostname={"maps.googleapis.com"} | ||
pathname={"/maps/api/js"} | ||
query={{v: `3.exp`, libraries: "geometry,drawing,places"}} | ||
// | ||
googleMapElement={ | ||
<GoogleMap | ||
defaultZoom={3} | ||
defaultCenter={{lat: -25.363882, lng: 131.044922}} | ||
onClick={::this._handle_map_click} | ||
/> | ||
} | ||
/> | ||
``` | ||
<a name="4.4.1"></a> | ||
@@ -2,0 +52,0 @@ ## [4.4.1](https://github.com/tomchentw/react-google-maps/compare/v4.4.0...v4.4.1) (2015-11-19) |
@@ -7,4 +7,2 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
@@ -26,6 +24,2 @@ | ||
var _canUseDom = require("can-use-dom"); | ||
var _canUseDom2 = _interopRequireDefault(_canUseDom); | ||
var _warning = require("warning"); | ||
@@ -37,5 +31,5 @@ | ||
var _utilsMakeUrl = require("../utils/makeUrl"); | ||
var _ScriptjsLoader = require("./ScriptjsLoader"); | ||
var _utilsMakeUrl2 = _interopRequireDefault(_utilsMakeUrl); | ||
var _ScriptjsLoader2 = _interopRequireDefault(_ScriptjsLoader); | ||
@@ -49,6 +43,2 @@ var ScriptjsGoogleMap = (function (_Component) { | ||
_get(Object.getPrototypeOf(ScriptjsGoogleMap.prototype), "constructor", this).apply(this, arguments); | ||
this.state = { | ||
isLoaded: false | ||
}; | ||
} | ||
@@ -59,8 +49,7 @@ | ||
value: function componentWillMount() { | ||
var _this = this; | ||
if (!_canUseDom2["default"]) { | ||
return; | ||
} | ||
var scriptjs = require("scriptjs"); | ||
(0, _warning2["default"])(false, "\"async/ScriptjsGoogleMap\" is deprecated now and will be removed in next major release (5.0.0). Use \"async/ScriptjsLoader\" instead.\nSee https://github.com/tomchentw/react-google-maps/pull/150 for more details."); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props; | ||
@@ -72,45 +61,21 @@ var protocol = _props.protocol; | ||
var query = _props.query; | ||
var loadingElement = _props.loadingElement; | ||
var children = _props.children; | ||
var restProps = _objectWithoutProperties(_props, ["protocol", "hostname", "port", "pathname", "query"]); | ||
var restProps = _objectWithoutProperties(_props, ["protocol", "hostname", "port", "pathname", "query", "loadingElement", "children"]); | ||
var urlObj = { protocol: protocol, hostname: hostname, port: port, pathname: pathname, query: query }; | ||
var url = (0, _utilsMakeUrl2["default"])(urlObj); | ||
scriptjs(url, function () { | ||
return _this.setState({ isLoaded: true }); | ||
return _react2["default"].createElement(_ScriptjsLoader2["default"], { | ||
protocol: protocol, | ||
hostname: hostname, | ||
port: port, | ||
pathname: pathname, | ||
query: query, | ||
loadingElement: loadingElement, | ||
googleMapElement: _react2["default"].createElement( | ||
_index.GoogleMap, | ||
restProps, | ||
children | ||
) | ||
}); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(nextProps) { | ||
if ("production" !== process.env.NODE_ENV) { | ||
var changedKeys = (0, _utilsMakeUrl.getUrlObjChangedKeys)(this.props, nextProps); | ||
(0, _warning2["default"])(0 === changedKeys.length, "ScriptjsGoogleMap doesn't support mutating url related props after initial render. Changed props: %s", "[" + changedKeys.join(", ") + "]"); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
if (this.state.isLoaded) { | ||
var _props2 = this.props; | ||
var protocol = _props2.protocol; | ||
var hostname = _props2.hostname; | ||
var port = _props2.port; | ||
var pathname = _props2.pathname; | ||
var query = _props2.query; | ||
var restProps = _objectWithoutProperties(_props2, ["protocol", "hostname", "port", "pathname", "query"]); | ||
return _react2["default"].createElement(_index.GoogleMap, restProps); | ||
} else { | ||
return this.props.loadingElement; | ||
} | ||
} | ||
}], [{ | ||
key: "propTypes", | ||
value: _extends({}, _utilsMakeUrl.urlObjDefinition, { | ||
// PropTypes for ScriptjsGoogleMap | ||
loadingElement: _react.PropTypes.node | ||
}), | ||
enumerable: true | ||
}]); | ||
@@ -117,0 +82,0 @@ |
{ | ||
"__template__gist__": "https://gist.github.com/tomchentw/368a93bb748ad9d576f1#file-package-json", | ||
"name": "react-google-maps", | ||
"version": "4.4.1", | ||
"version": "4.5.0", | ||
"description": "React.js Google Maps integration component", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
import { | ||
default as React, | ||
Component, | ||
PropTypes, | ||
} from "react"; | ||
import { | ||
default as canUseDOM, | ||
} from "can-use-dom"; | ||
import { | ||
default as warning, | ||
@@ -20,47 +15,33 @@ } from "warning"; | ||
import { | ||
default as makeUrl, | ||
urlObjDefinition, | ||
getUrlObjChangedKeys, | ||
} from "../utils/makeUrl"; | ||
default as ScriptjsLoader, | ||
} from "./ScriptjsLoader"; | ||
export default class ScriptjsGoogleMap extends Component { | ||
static propTypes = { | ||
...urlObjDefinition, | ||
// PropTypes for ScriptjsGoogleMap | ||
loadingElement: PropTypes.node, | ||
} | ||
state = { | ||
isLoaded: false, | ||
} | ||
componentWillMount () { | ||
if (!canUseDOM) { | ||
return; | ||
} | ||
const scriptjs = require("scriptjs"); | ||
const {protocol, hostname, port, pathname, query, ...restProps} = this.props; | ||
const urlObj = {protocol, hostname, port, pathname, query}; | ||
const url = makeUrl(urlObj); | ||
scriptjs(url, () => this.setState({ isLoaded: true })); | ||
warning(false, | ||
`"async/ScriptjsGoogleMap" is deprecated now and will be removed in next major release (5.0.0). Use "async/ScriptjsLoader" instead. | ||
See https://github.com/tomchentw/react-google-maps/pull/150 for more details.` | ||
); | ||
} | ||
componentWillReceiveProps (nextProps) { | ||
if ("production" !== process.env.NODE_ENV) { | ||
const changedKeys = getUrlObjChangedKeys(this.props, nextProps); | ||
render () { | ||
const {protocol, hostname, port, pathname, query, loadingElement, children, ...restProps} = this.props; | ||
warning(0 === changedKeys.length, `ScriptjsGoogleMap doesn't support mutating url related props after initial render. Changed props: %s`, `[${ changedKeys.join(", ") }]`); | ||
} | ||
return ( | ||
<ScriptjsLoader | ||
protocol={protocol} | ||
hostname={hostname} | ||
port={port} | ||
pathname={pathname} | ||
query={query} | ||
loadingElement={loadingElement} | ||
googleMapElement={ | ||
<GoogleMap {...restProps}> | ||
{children} | ||
</GoogleMap> | ||
} | ||
/> | ||
) | ||
} | ||
render () { | ||
if (this.state.isLoaded) { | ||
const {protocol, hostname, port, pathname, query, ...restProps} = this.props; | ||
return ( | ||
<GoogleMap {...restProps} /> | ||
); | ||
} else { | ||
return this.props.loadingElement; | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
321921
108
6154