Skip to content

Commit

Permalink
UIEUS-355: avoid default props (#473)
Browse files Browse the repository at this point in the history
* UIEUS-355-avoid-defaultProps

* UIEUS-355-avoid-defaultProps

* UIEUS-355-avoid-defaultProps

* UIEUS-355-avoid-defaultProps

---------

Co-authored-by: elsenhans <[email protected]>
  • Loading branch information
elsenhans and elsenhans authored Jul 9, 2024
1 parent 2a87c2d commit 44b6041
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 9.1.0 (IN PROGRESS)
* Fix bug in JobView test ([UIEUS-360](https://folio-org.atlassian.net/browse/UIEUS-360))
* React v19: refactor away from default props for functional components ([UIEUS-355](https://folio-org.atlassian.net/browse/UIEUS-355))

## [9.0.0](https://github.com/folio-org/ui-erm-usage/tree/v9.0.0) (2024-04-17)
* *BREAKING* Use `multipart/form-data` to upload COUNTER reports ([UIEUS-353](https://folio-org.atlassian.net/browse/UIEUS-353))
Expand Down
6 changes: 1 addition & 5 deletions src/components/JobsView/JobsViewResultCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { memo } from 'react';
import styles from './JobsView.css';

const JobsViewResultCell = ({ errorMessage, text }) => {
const JobsViewResultCell = ({ errorMessage = '', text }) => {
const textWithInfo = (
<span className={styles.alignCentered}>
{text}
Expand All @@ -19,8 +19,4 @@ JobsViewResultCell.propTypes = {
text: PropTypes.string.isRequired
};

JobsViewResultCell.defaultProps = {
errorMessage: ''
};

export default memo(JobsViewResultCell);
9 changes: 1 addition & 8 deletions src/components/UDPHeader/UDPHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useStripes } from '@folio/stripes/core';
import harvestingStatusOptions from '../../util/data/harvestingStatusOptions';
import css from './UDPHeader.css';

const UDPHeader = ({ usageDataProvider, lastJob }) => {
const UDPHeader = ({ usageDataProvider = { harvestingConfig: {} }, lastJob = {} }) => {
const stripes = useStripes();
const {
latestReport,
Expand Down Expand Up @@ -60,13 +60,6 @@ const UDPHeader = ({ usageDataProvider, lastJob }) => {
);
};

UDPHeader.defaultProps = {
usageDataProvider: {
harvestingConfig: {},
},
lastJob: {},
};

UDPHeader.propTypes = {
usageDataProvider: PropTypes.shape({
latestReport: PropTypes.string,
Expand Down
6 changes: 1 addition & 5 deletions src/routes/UDPViewRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { MAX_FAILED_ATTEMPTS } from '../util/constants';

function UDPViewRoute(props) {
const {
handlers,
handlers = {},
mutator,
resources,
stripes,
Expand Down Expand Up @@ -185,10 +185,6 @@ UDPViewRoute.propTypes = {
tagsEnabled: PropTypes.bool,
};

UDPViewRoute.defaultProps = {
handlers: {},
};

UDPViewRoute.manifest = Object.freeze({
usageDataProvider: {
type: 'okapi',
Expand Down
6 changes: 1 addition & 5 deletions src/routes/components/withReportHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default function withReportHandlers(WrappedComponent) {
});
};

const { handlers, ...rest } = props;
const { handlers = {}, ...rest } = props;

return (
<>
Expand Down Expand Up @@ -155,9 +155,5 @@ export default function withReportHandlers(WrappedComponent) {
intl: PropTypes.object,
};

WithReportHandlers.defaultProps = {
handlers: {},
};

return withStripes(injectIntl(WithReportHandlers));
}

0 comments on commit 44b6041

Please sign in to comment.