Skip to content

Commit

Permalink
refactor: simplify code for passing displayProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Nov 24, 2023
1 parent 22c9b0d commit 4a85a12
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/components/Visualization/Visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import debounce from 'lodash-es/debounce'
import PropTypes from 'prop-types'
import React, { Component, Fragment } from 'react'
import { connect } from 'react-redux'
import { createSelector } from 'reselect'
import { acSetChart } from '../../actions/chart.js'
import { tSetCurrentFromUi } from '../../actions/current.js'
import { acSetLoadError, acSetPluginLoading } from '../../actions/loader.js'
Expand Down Expand Up @@ -183,7 +182,7 @@ export class UnconnectedVisualization extends Component {
render() {
const {
visualization,
userSettings,
displayProperty,
error,
isLoading,
onLoadingComplete,
Expand All @@ -208,7 +207,7 @@ export class UnconnectedVisualization extends Component {
onError={this.onError}
onDrill={this.onDrill}
style={styles.chartCanvas}
displayProperty={userSettings.displayProperty}
displayProperty={displayProperty}
/>
</Fragment>
)
Expand All @@ -218,31 +217,24 @@ export class UnconnectedVisualization extends Component {
UnconnectedVisualization.propTypes = {
addMetadata: PropTypes.func,
addParentGraphMap: PropTypes.func,
displayProperty: PropTypes.string,
error: PropTypes.object,
isLoading: PropTypes.bool,
rightSidebarOpen: PropTypes.bool,
setChart: PropTypes.func,
setCurrent: PropTypes.func,
setLoadError: PropTypes.func,
setUiItems: PropTypes.func,
userSettings: PropTypes.object,
visualization: PropTypes.object,
onLoadingComplete: PropTypes.func,
}

export const userSettingsSelector = createSelector(
[sGetSettingsDisplayProperty],
(displayProperty) => ({
displayProperty,
})
)

const mapStateToProps = (state) => ({
visualization: sGetCurrent(state),
rightSidebarOpen: sGetUiRightSidebarOpen(state),
error: sGetLoadError(state),
isLoading: sGetIsPluginLoading(state),
userSettings: userSettingsSelector(state),
displayProperty: sGetSettingsDisplayProperty(state),
})

const mapDispatchToProps = (dispatch) => ({
Expand Down

0 comments on commit 4a85a12

Please sign in to comment.