Skip to content

Commit

Permalink
UIREQ-1101: React v19: refactor away from default props for functiona…
Browse files Browse the repository at this point in the history
…l components
  • Loading branch information
Dmitriy-Litvinenko committed Dec 16, 2024
1 parent cab7e2f commit 4362173
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Increase code coverage for src/ChooseRequestTypeDialog.js by Jest/RTL tests. Refs UIREQ-1044.
* Cleanup retrieval service point implementation from deprecated folder. Refs UIREQ-1211.
* Increase code coverage for src/ViewRequest.js by Jest/RTL tests. Refs UIREQ-1046.
* React v19: refactor away from default props for functional components. Refs UIREQ-1101.

## [11.0.2] (https://github.com/folio-org/ui-requests/tree/v11.0.2) (2024-12-10)
[Full Changelog](https://github.com/folio-org/ui-requests/compare/v11.0.1...v11.0.2)
Expand Down
6 changes: 1 addition & 5 deletions src/ItemsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const ItemsDialog = ({
onRowClick = noop,
mutator,
skippedItemId,
title,
title = '',
instanceId,
}) => {
const [areItemsBeingLoaded, setAreItemsBeingLoaded] = useState(false);
Expand Down Expand Up @@ -233,10 +233,6 @@ ItemsDialog.manifest = {
},
};

ItemsDialog.defaultProps = {
title: '',
};

ItemsDialog.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
Expand Down
15 changes: 4 additions & 11 deletions src/components/FulfilmentPreference/FulfilmentPreference.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ const {

const FulfilmentPreference = ({
isEditForm,
deliverySelected,
deliveryAddress,
deliverySelected = false,
deliveryAddress = '',
onChangeAddress,
deliveryLocations,
fulfillmentTypeOptions,
deliveryLocations = [],
fulfillmentTypeOptions = [],
defaultDeliveryAddressTypeId,
changeDeliveryAddress,
requestTypes,
Expand Down Expand Up @@ -167,11 +167,4 @@ FulfilmentPreference.propTypes = {
deliverySelected: PropTypes.bool,
};

FulfilmentPreference.defaultProps = {
deliveryAddress: '',
deliveryLocations: [],
fulfillmentTypeOptions: [],
deliverySelected: false,
};

export default FulfilmentPreference;
6 changes: 1 addition & 5 deletions src/components/PrintContent/PrintContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import css from './PrintContent.css';
const PrintContent = forwardRef(({
dataSource,
template,
id,
id = 'printContent',
}, ref) => {
const templateFn = useMemo(() => buildTemplate(template), [template]);

Expand Down Expand Up @@ -43,8 +43,4 @@ PrintContent.propTypes = {
template: PropTypes.string.isRequired,
};

PrintContent.defaultProps = {
id: 'printContent',
};

export default memo(PrintContent, isEqual);
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
} from '../../../constants';

const PickupServicePointFilter = ({
activeValues,
servicePoints,
activeValues = [],
servicePoints = [],
onChange,
onClear,
}) => {
Expand Down Expand Up @@ -67,9 +67,4 @@ PickupServicePointFilter.propTypes = {
onClear: PropTypes.func.isRequired,
};

PickupServicePointFilter.defaultProps = {
activeValues: [],
servicePoints: [],
};

export default PickupServicePointFilter;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '../../../constants';

const RequestLevelFilter = ({
activeValues,
activeValues = [],
onChange,
onClear,
}) => {
Expand Down Expand Up @@ -63,8 +63,4 @@ RequestLevelFilter.propTypes = {
onClear: PropTypes.func.isRequired,
};

RequestLevelFilter.defaultProps = {
activeValues: [],
};

export default RequestLevelFilter;
12 changes: 3 additions & 9 deletions src/components/SortableList/SortableList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import draggableRowFormatter from './draggableRowFormatter';

export default function SortableList(props) {
const {
droppableId,
droppableId = uniqueId('droppable'),
onDragEnd,
rowFormatter,
isRowDraggable,
rowFormatter = draggableRowFormatter,
isRowDraggable = () => true,
rowProps,
visibleColumns: originalVisibleColumns,
columnWidths: originalColumnWidths,
Expand Down Expand Up @@ -73,12 +73,6 @@ export default function SortableList(props) {
);
}

SortableList.defaultProps = {
droppableId: uniqueId('droppable'),
rowFormatter: draggableRowFormatter,
isRowDraggable: () => true,
};

SortableList.propTypes = {
droppableId: PropTypes.string,
onDragEnd: PropTypes.func,
Expand Down
18 changes: 5 additions & 13 deletions src/components/TitleInformation/TitleInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export const getIdentifiers = (data, separator, limit) => data.slice(0, limit).m

const TitleInformation = (props) => {
const {
titleLevelRequestsLink,
titleLevelRequestsLink = true,
holdingsRecordId,
instanceId,
titleLevelRequestsCount,
title,
contributors,
publications,
editions,
identifiers,
contributors = [],
publications = [],
editions = [],
identifiers = [],
intl:{
formatMessage,
},
Expand Down Expand Up @@ -95,14 +95,6 @@ const TitleInformation = (props) => {
);
};

TitleInformation.defaultProps = {
contributors: [],
publications: [],
editions: [],
identifiers: [],
titleLevelRequestsLink: true,
};

TitleInformation.propTypes = {
titleLevelRequestsLink: PropTypes.bool,
titleLevelRequestsCount: PropTypes.number.isRequired,
Expand Down

0 comments on commit 4362173

Please sign in to comment.