Skip to content

Commit

Permalink
remove deprecated react lifecycle methods (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored and Xiaoji Chen committed Aug 13, 2019
1 parent 0b2cecb commit a4e3620
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 182 deletions.
4 changes: 3 additions & 1 deletion examples/deckgl-overlay/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {render} from 'react-dom';
import DeckGL, {ArcLayer} from 'deck.gl';
import MapGL from 'react-map-gl';

const TOKEN = ''; // Set your mapbox token here

export default class App extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -31,7 +33,7 @@ export default class App extends Component {
height="100%"
maxPitch={85}
onViewportChange={this._onViewportChange}
mapboxApiAccessToken="<YOUR TOKEN HERE>"
mapboxApiAccessToken={TOKEN}
>
<DeckGL
viewState={viewport}
Expand Down
167 changes: 0 additions & 167 deletions examples/deckgl-overlay/view.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/main/example-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class App extends Component {
};
}

UNSAFE_componentWillMount() {
componentDidMount() {
window.onresize = () =>
this.setState({
viewport: {
Expand Down
2 changes: 1 addition & 1 deletion examples/main/views/style-diffing.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class StyleDiffingExample extends Component {
this._onClick = this._onClick.bind(this);
}

UNSAFE_componentWillMount() {
componentDidMount() {
const colors = ['red', 'green', 'blue'];
let i = 0;
this._intervalId = window.setInterval(
Expand Down
20 changes: 8 additions & 12 deletions src/components/interactive-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,6 @@ export default class InteractiveMap extends PureComponent<InteractiveMapProps, S
this._updateInteractiveContext({mapContainer});
}

UNSAFE_componentWillUpdate(nextProps: InteractiveMapProps, nextState: State) {
this._setControllerProps(nextProps);

if (nextState.isDragging !== this.state.isDragging) {
this._updateInteractiveContext({isDragging: nextState.isDragging});
}
}

componentWillUnmount() {
this._eventManager.destroy();
}
Expand Down Expand Up @@ -286,10 +278,11 @@ export default class InteractiveMap extends PureComponent<InteractiveMapProps, S

this._controller.setOptions(props);

this._updateInteractiveContext({
onViewStateChange: props.onViewStateChange,
onViewportChange: props.onViewportChange
});
// Pass callbacks via MapContext
// Do not create a new context object because these do not affect render
const context = this._interactiveContext;
context.onViewportChange = props.onViewportChange;
context.onViewStateChange = props.onViewStateChange;
}

_getFeatures({pos, radius}: {pos: Array<number>, radius: number}) {
Expand All @@ -315,6 +308,7 @@ export default class InteractiveMap extends PureComponent<InteractiveMapProps, S
_onInteractionStateChange = (interactionState: InteractionState) => {
const {isDragging = false} = interactionState;
if (isDragging !== this.state.isDragging) {
this._updateInteractiveContext({isDragging});
this.setState({isDragging});
}

Expand Down Expand Up @@ -495,6 +489,8 @@ export default class InteractiveMap extends PureComponent<InteractiveMapProps, S
};

render() {
this._setControllerProps(this.props);

const {width, height, style, getCursor} = this.props;

const eventCanvasStyle = Object.assign({position: 'relative'}, style, {
Expand Down

0 comments on commit a4e3620

Please sign in to comment.