Skip to content

Commit

Permalink
UIEUS-355-avoid-defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
elsenhans committed Jun 13, 2024
1 parent b9e1974 commit 261e45c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/components/Counter/CounterStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class CounterStatistics extends React.Component {
}).isRequired,
};

static defaultProps = {
infoText: <FormattedMessage id="ui-erm-usage.reportOverview.infoText" />
}

constructor(props) {
super(props);
this.downloadableReports = this.calcDownloadableReportTypes();
Expand All @@ -53,10 +57,7 @@ class CounterStatistics extends React.Component {
};

render() {
const {
infoText = <FormattedMessage id="ui-erm-usage.reportOverview.infoText" />,
showMultiMonthDownload,
} = this.props;
const { infoText, showMultiMonthDownload } = this.props;

return (
<>
Expand Down
12 changes: 8 additions & 4 deletions src/components/UDPFilters/UDPFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class UDPFilters extends React.Component {
intl: PropTypes.object
});

static defaultProps = {
activeFilters: {}
};

static getDerivedStateFromProps(props, state) {
const newState = {};
const arr = [];
Expand Down Expand Up @@ -118,7 +122,7 @@ class UDPFilters extends React.Component {
};

renderCheckboxFilter = (key, closedByDefault = false) => {
const { activeFilters = {} } = this.props;
const { activeFilters } = this.props;
const groupFilters = activeFilters[key] || [];

return (
Expand Down Expand Up @@ -149,7 +153,7 @@ class UDPFilters extends React.Component {
};

renderTagsFilter = () => {
const { activeFilters = {} } = this.props;
const { activeFilters } = this.props;
const tagFilters = activeFilters.tags || [];

return (
Expand Down Expand Up @@ -181,7 +185,7 @@ class UDPFilters extends React.Component {
};

renderErrorCodesFilter = () => {
const { activeFilters = {} } = this.props;
const { activeFilters } = this.props;
const errorCodesFilters = activeFilters.errorCodes || [];

return (
Expand Down Expand Up @@ -213,7 +217,7 @@ class UDPFilters extends React.Component {
};

renderReportTypesFiler = () => {
const { activeFilters = {} } = this.props;
const { activeFilters } = this.props;
const reportTypesFilters = activeFilters.reportTypes || [];

return (
Expand Down
11 changes: 7 additions & 4 deletions src/components/views/UDPForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class UDPForm extends React.Component {
submitting: PropTypes.bool,
};

static defaultProps = {
initialValues: {},
};

constructor(props) {
super(props);

Expand Down Expand Up @@ -153,7 +157,7 @@ class UDPForm extends React.Component {
}

renderLastMenu() {
const { initialValues = {} } = this.props;
const { initialValues } = this.props;
const { confirmDelete } = this.state;
const isEditing = initialValues && initialValues.id;

Expand Down Expand Up @@ -247,19 +251,18 @@ class UDPForm extends React.Component {
};

renderFormPaneHeader = () => {
const { initialValues = {} } = this.props;
return (
<PaneHeader
firstMenu={this.renderFirstMenu()}
lastMenu={this.renderLastMenu()}
paneTitle={initialValues.id ? initialValues.label : <FormattedMessage id="ui-erm-usage.udp.form.createUDP" />}
paneTitle={this.props.initialValues.id ? this.props.initialValues.label : <FormattedMessage id="ui-erm-usage.udp.form.createUDP" />}
/>
);
};

render() {
const {
initialValues = {},
initialValues,
handleSubmit,
data: { aggregators, harvesterImpls },
} = this.props;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/UDPs.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class UDPs extends React.Component {
const {
children,
contentRef,
data = {},
data,
intl,
onNeedMoreData,
onSelectRow,
Expand Down

0 comments on commit 261e45c

Please sign in to comment.