Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary rerenders #379

Merged
merged 1 commit into from
Jun 4, 2021
Merged
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
11 changes: 4 additions & 7 deletions lib/components/map/connected-transitive-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import TransitiveOverlay from '@opentripplanner/transitive-overlay'
import React, { Component } from 'react'
import { connect } from 'react-redux'

import { getActiveSearch, getTransitiveData } from '../../util/state'
import { getTransitiveData } from '../../util/state'

/**
* Wrapper for TransitiveOverlay that avoids rerenders by checking transitive
Expand All @@ -14,10 +14,11 @@ class TransitiveCanvasOverlay extends Component {
}

render () {
const { transitiveData, ...otherProps } = this.props
const { labeledModes, styles, transitiveData } = this.props
return (
<TransitiveOverlay
{...otherProps}
labeledModes={labeledModes}
styles={styles}
transitiveData={transitiveData}
/>
)
Expand All @@ -27,14 +28,10 @@ class TransitiveCanvasOverlay extends Component {
// connect to the redux store

const mapStateToProps = (state, ownProps) => {
const activeSearch = getActiveSearch(state.otp)
const { activeItinerary, query } = activeSearch || {}
const { labeledModes, styles } = state.otp.config.map.transitive || {}

return {
activeItinerary,
labeledModes,
routingType: query && query.routingType,
styles,
transitiveData: getTransitiveData(state, ownProps)
}
Expand Down
7 changes: 0 additions & 7 deletions lib/components/map/default-map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import BaseMap from '@opentripplanner/base-map'
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import styled from 'styled-components'
Expand Down Expand Up @@ -123,7 +122,6 @@ class DefaultMap extends Component {
bikeRentalStations,
carRentalQuery,
carRentalStations,
itineraryView,
mapConfig,
mapPopupLocation,
vehicleRentalQuery,
Expand Down Expand Up @@ -169,9 +167,6 @@ class DefaultMap extends Component {
*/}
<TransitiveOverlay
getTransitiveRouteLabel={this.context.getTransitiveRouteLabel}
key={itineraryView
? `transitive-${itineraryView}`
: 'transitive-default'}
/>
<TripViewerOverlay />
<ElevationPointMarker />
Expand Down Expand Up @@ -223,12 +218,10 @@ const mapStateToProps = (state, ownProps) => {
const overlays = state.otp.config.map && state.otp.config.map.overlays
? state.otp.config.map.overlays
: []
const urlParams = coreUtils.query.getUrlParams()

return {
bikeRentalStations: state.otp.overlay.bikeRental.stations,
carRentalStations: state.otp.overlay.carRental.stations,
itineraryView: urlParams.ui_itineraryView,
mapConfig: state.otp.config.map,
mapPopupLocation: state.otp.ui.mapPopupLocation,
overlays,
Expand Down