Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Geographies.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class Geographies extends Component {
this.parseGeographies(props.geography)
}
}
componentWillReceiveProps(nextProps) {
if (nextProps.geography !== this.props.geography) {
if (this.shouldFetchGeographies(nextProps.geography)) {
this.fetchGeographies(nextProps.geography)
componentDidUpdate(prevProps) {
if (prevProps.geography !== this.props.geography) {
if (this.shouldFetchGeographies(prevProps.geography)) {
this.fetchGeographies(prevProps.geography)
} else {
this.setState({
geographyPaths: this.parseGeographies(nextProps.geography)
geographyPaths: this.parseGeographies(prevProps.geography)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Graticule.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Graticule extends Component {
: computeOutline(projection),
})
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
const {
step,
projection,
Expand All @@ -54,12 +54,12 @@ class Graticule extends Component {
globe,
} = this.props

if (nextProps.round !== round || nextProps.precision !== precision || globe) {
if (prevProps.round !== round || prevProps.precision !== precision || globe) {
this.setState({
graticulePath: nextProps.round
graticulePath: prevProps.round
? roundPath(computeGraticule(projection, step), precision)
: computeGraticule(projection, step),
outlinePath: nextProps.round
outlinePath: prevProps.round
? roundPath(computeOutline(projection), precision)
: computeOutline(projection),
})
Expand Down
10 changes: 5 additions & 5 deletions src/ZoomableGlobe.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ class ZoomableGlobe extends Component {
evt.preventDefault()
}
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
const { mouseX, mouseY } = this.state
const { projection, center, zoom } = this.props

const zoomFactor = nextProps.zoom / zoom
const centerChanged = JSON.stringify(nextProps.center) !== JSON.stringify(center)
const zoomFactor = prevProps.zoom / zoom
const centerChanged = JSON.stringify(prevProps.center) !== JSON.stringify(center)

this.setState({
zoom: nextProps.zoom,
rotation: centerChanged ? [-nextProps.center[0], -nextProps.center[1], this.state.rotation[2]] : this.state.rotation,
zoom: prevProps.zoom,
rotation: centerChanged ? [-prevProps.center[0], -prevProps.center[1], this.state.rotation[2]] : this.state.rotation,
})
}
componentDidMount() {
Expand Down
12 changes: 6 additions & 6 deletions src/ZoomableGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ class ZoomableGroup extends Component {
evt.preventDefault()
}
}
componentWillReceiveProps(nextProps) {
componentDidUpdate(prevProps) {
const { mouseX, mouseY, resizeFactorX, resizeFactorY } = this.state
const { projection, center, zoom } = this.props

const zoomFactor = nextProps.zoom / zoom
const centerChanged = JSON.stringify(nextProps.center) !== JSON.stringify(center)
const zoomFactor = prevProps.zoom / zoom
const centerChanged = JSON.stringify(prevProps.center) !== JSON.stringify(center)

this.setState({
zoom: nextProps.zoom,
mouseX: centerChanged ? calculateMousePosition("x", nextProps.projection, nextProps, nextProps.zoom, resizeFactorX) : mouseX * zoomFactor,
mouseY: centerChanged ? calculateMousePosition("y", nextProps.projection, nextProps, nextProps.zoom, resizeFactorY) : mouseY * zoomFactor,
zoom: prevProps.zoom,
mouseX: centerChanged ? calculateMousePosition("x", prevProps.projection, prevProps, prevProps.zoom, resizeFactorX) : mouseX * zoomFactor,
mouseY: centerChanged ? calculateMousePosition("y", prevProps.projection, prevProps, prevProps.zoom, resizeFactorY) : mouseY * zoomFactor,
})
}
handleResize() {
Expand Down