-
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(Polyline): revamp with jscodeshift
- Loading branch information
Showing
2 changed files
with
85 additions
and
132 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,85 @@ | ||
/* global google */ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import { | ||
construct, | ||
componentDidMount, | ||
componentDidUpdate, | ||
componentWillUnmount, | ||
} from "../utils/MapChildHelper" | ||
|
||
import { MAP, POLYLINE } from "../constants" | ||
|
||
export const __jscodeshiftPlaceholder__ = `{ | ||
"eventMapOverrides": { | ||
"onDblClick": "dblclick", | ||
"onDragEnd": "dragend", | ||
"onDragStart": "dragstart", | ||
"onMouseDown": "mousedown", | ||
"onMouseMove": "mousemove", | ||
"onMouseOut": "mouseout", | ||
"onMouseOver": "mouseover", | ||
"onMouseUp": "mouseup", | ||
"onRightClick": "rightclick" | ||
}, | ||
"getInstanceFromComponent": "this.state[POLYLINE]" | ||
}` | ||
|
||
/** | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline | ||
*/ | ||
export class Polyline extends React.PureComponent { | ||
static propTypes = { | ||
__jscodeshiftPlaceholder__: null, | ||
} | ||
|
||
static contextTypes = { | ||
[MAP]: PropTypes.object, | ||
} | ||
|
||
/* | ||
* @url https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline | ||
*/ | ||
constructor(props, context) { | ||
super(props, context) | ||
const polyline = new google.maps.Polyline() | ||
construct(Polyline.propTypes, updaterMap, this.props, polyline) | ||
polyline.setMap(this.context[MAP]) | ||
this.state = { | ||
[POLYLINE]: polyline, | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
componentDidMount(this, this.state[POLYLINE], eventMap) | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
componentDidUpdate( | ||
this, | ||
this.state[POLYLINE], | ||
eventMap, | ||
updaterMap, | ||
prevProps | ||
) | ||
} | ||
|
||
componentWillUnmount() { | ||
componentWillUnmount(this) | ||
const polyline = this.state[POLYLINE] | ||
if (polyline) { | ||
polyline.setMap(null) | ||
} | ||
} | ||
|
||
render() { | ||
return false | ||
} | ||
} | ||
|
||
export default Polyline | ||
|
||
const eventMap = {} | ||
|
||
const updaterMap = {} |