-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(visualization/HeatmapLayer): revamp with jscodeshift
- Loading branch information
Showing
4 changed files
with
84 additions
and
108 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* global google */ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import { | ||
construct, | ||
componentDidMount, | ||
componentDidUpdate, | ||
componentWillUnmount, | ||
} from "../../utils/MapChildHelper" | ||
|
||
import { MAP, HEATMAP_LAYER } from "../../constants" | ||
|
||
export const __jscodeshiftPlaceholder__ = `{ | ||
"eventMapOverrides": { | ||
}, | ||
"getInstanceFromComponent": "this.state[HEATMAP_LAYER]" | ||
}` | ||
|
||
/** | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#HeatmapLayer | ||
*/ | ||
export class HeatmapLayer extends React.PureComponent { | ||
static propTypes = { | ||
__jscodeshiftPlaceholder__: null, | ||
} | ||
|
||
static contextTypes = { | ||
[MAP]: PropTypes.object, | ||
} | ||
|
||
/* | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#HeatmapLayer | ||
*/ | ||
constructor(props, context) { | ||
super(props, context) | ||
const heatmapLayer = new google.maps.visualization.HeatmapLayer() | ||
construct(HeatmapLayer.propTypes, updaterMap, this.props, heatmapLayer) | ||
heatmapLayer.setMap(this.context[MAP]) | ||
this.state = { | ||
[HEATMAP_LAYER]: heatmapLayer, | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
componentDidMount(this, this.state[HEATMAP_LAYER], eventMap) | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
componentDidUpdate( | ||
this, | ||
this.state[HEATMAP_LAYER], | ||
eventMap, | ||
updaterMap, | ||
prevProps | ||
) | ||
} | ||
|
||
componentWillUnmount() { | ||
componentWillUnmount(this) | ||
const heatmapLayer = this.state[HEATMAP_LAYER] | ||
if (heatmapLayer) { | ||
heatmapLayer.setMap(null) | ||
} | ||
} | ||
|
||
render() { | ||
return false | ||
} | ||
} | ||
|
||
export default HeatmapLayer | ||
|
||
const eventMap = {} | ||
|
||
const updaterMap = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import warning from "warning" | ||
|
||
warning( | ||
false, | ||
`[DEPRECATED] "react-google-maps/lib/visualization/HeatmapLayer" has been moved to "react-google-maps/lib/components/visualization/HeatmapLayer".` | ||
) | ||
|
||
export { default } from "../components/visualization/HeatmapLayer" |