Skip to content

Commit

Permalink
feat(visualization/HeatmapLayer): revamp with jscodeshift
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Sep 13, 2017
1 parent bc41752 commit b92a570
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 108 deletions.
99 changes: 0 additions & 99 deletions src/lib/visualization/HeatmapLayer.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/lib/visualization/heatmapLayer.spec.js

This file was deleted.

76 changes: 76 additions & 0 deletions src/macros/visualization/HeatmapLayer.jsx
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 = {}
8 changes: 8 additions & 0 deletions src/visualization/HeatmapLayer.js
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"

0 comments on commit b92a570

Please sign in to comment.