-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FusionTablesLayer): revamp with jscodeshift
- Loading branch information
Showing
2 changed files
with
81 additions
and
98 deletions.
There are no files selected for viewing
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,81 @@ | ||
/* global google */ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import { | ||
construct, | ||
componentDidMount, | ||
componentDidUpdate, | ||
componentWillUnmount, | ||
} from "../utils/MapChildHelper" | ||
|
||
import { MAP, FUSION_TABLES_LAYER } from "../constants" | ||
|
||
export const __jscodeshiftPlaceholder__ = `{ | ||
"eventMapOverrides": { | ||
}, | ||
"getInstanceFromComponent": "this.state[FUSION_TABLES_LAYER]" | ||
}` | ||
|
||
/** | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#FusionTablesLayer | ||
*/ | ||
export class FusionTablesLayer extends React.PureComponent { | ||
static propTypes = { | ||
__jscodeshiftPlaceholder__: null, | ||
} | ||
|
||
static contextTypes = { | ||
[MAP]: PropTypes.object, | ||
} | ||
|
||
/* | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#FusionTablesLayer | ||
*/ | ||
constructor(props, context) { | ||
super(props, context) | ||
const fusionTablesLayer = new google.maps.FusionTablesLayer() | ||
construct( | ||
FusionTablesLayer.propTypes, | ||
updaterMap, | ||
this.props, | ||
fusionTablesLayer | ||
) | ||
fusionTablesLayer.setMap(this.context[MAP]) | ||
this.state = { | ||
[FUSION_TABLES_LAYER]: fusionTablesLayer, | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
componentDidMount(this, this.state[FUSION_TABLES_LAYER], eventMap) | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
componentDidUpdate( | ||
this, | ||
this.state[FUSION_TABLES_LAYER], | ||
eventMap, | ||
updaterMap, | ||
prevProps | ||
) | ||
} | ||
|
||
componentWillUnmount() { | ||
componentWillUnmount(this) | ||
const fusionTablesLayer = this.state[FUSION_TABLES_LAYER] | ||
if (fusionTablesLayer) { | ||
fusionTablesLayer.setMap(null) | ||
} | ||
} | ||
|
||
render() { | ||
return false | ||
} | ||
} | ||
|
||
export default FusionTablesLayer | ||
|
||
const eventMap = {} | ||
|
||
const updaterMap = {} |