diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e13c83b..0a399006b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/ItemsDialog.js b/src/ItemsDialog.js index 1dd777543..1ffd64c62 100644 --- a/src/ItemsDialog.js +++ b/src/ItemsDialog.js @@ -79,7 +79,7 @@ const ItemsDialog = ({ onRowClick = noop, mutator, skippedItemId, - title, + title = '', instanceId, }) => { const [areItemsBeingLoaded, setAreItemsBeingLoaded] = useState(false); @@ -233,10 +233,6 @@ ItemsDialog.manifest = { }, }; -ItemsDialog.defaultProps = { - title: '', -}; - ItemsDialog.propTypes = { open: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, diff --git a/src/components/FulfilmentPreference/FulfilmentPreference.js b/src/components/FulfilmentPreference/FulfilmentPreference.js index 714d46cbb..b2cb978f2 100644 --- a/src/components/FulfilmentPreference/FulfilmentPreference.js +++ b/src/components/FulfilmentPreference/FulfilmentPreference.js @@ -26,11 +26,11 @@ const { const FulfilmentPreference = ({ isEditForm, - deliverySelected, - deliveryAddress, + deliverySelected = false, + deliveryAddress = '', onChangeAddress, - deliveryLocations, - fulfillmentTypeOptions, + deliveryLocations = [], + fulfillmentTypeOptions = [], defaultDeliveryAddressTypeId, changeDeliveryAddress, requestTypes, @@ -167,11 +167,4 @@ FulfilmentPreference.propTypes = { deliverySelected: PropTypes.bool, }; -FulfilmentPreference.defaultProps = { - deliveryAddress: '', - deliveryLocations: [], - fulfillmentTypeOptions: [], - deliverySelected: false, -}; - export default FulfilmentPreference; diff --git a/src/components/PrintContent/PrintContent.js b/src/components/PrintContent/PrintContent.js index 565bf9c3c..9ff878d7a 100644 --- a/src/components/PrintContent/PrintContent.js +++ b/src/components/PrintContent/PrintContent.js @@ -10,7 +10,7 @@ import css from './PrintContent.css'; const PrintContent = forwardRef(({ dataSource, template, - id, + id = 'printContent', }, ref) => { const templateFn = useMemo(() => buildTemplate(template), [template]); @@ -43,8 +43,4 @@ PrintContent.propTypes = { template: PropTypes.string.isRequired, }; -PrintContent.defaultProps = { - id: 'printContent', -}; - export default memo(PrintContent, isEqual); diff --git a/src/components/RequestsFilters/PickupServicePointFilter/PickupServicePointFilter.js b/src/components/RequestsFilters/PickupServicePointFilter/PickupServicePointFilter.js index dfabb668f..7362de426 100644 --- a/src/components/RequestsFilters/PickupServicePointFilter/PickupServicePointFilter.js +++ b/src/components/RequestsFilters/PickupServicePointFilter/PickupServicePointFilter.js @@ -19,8 +19,8 @@ import { } from '../../../constants'; const PickupServicePointFilter = ({ - activeValues, - servicePoints, + activeValues = [], + servicePoints = [], onChange, onClear, }) => { @@ -67,9 +67,4 @@ PickupServicePointFilter.propTypes = { onClear: PropTypes.func.isRequired, }; -PickupServicePointFilter.defaultProps = { - activeValues: [], - servicePoints: [], -}; - export default PickupServicePointFilter; diff --git a/src/components/RequestsFilters/RequestLevelFilter/RequestLevelFilter.js b/src/components/RequestsFilters/RequestLevelFilter/RequestLevelFilter.js index 25c6f2b27..9c178dad5 100644 --- a/src/components/RequestsFilters/RequestLevelFilter/RequestLevelFilter.js +++ b/src/components/RequestsFilters/RequestLevelFilter/RequestLevelFilter.js @@ -18,7 +18,7 @@ import { } from '../../../constants'; const RequestLevelFilter = ({ - activeValues, + activeValues = [], onChange, onClear, }) => { @@ -63,8 +63,4 @@ RequestLevelFilter.propTypes = { onClear: PropTypes.func.isRequired, }; -RequestLevelFilter.defaultProps = { - activeValues: [], -}; - export default RequestLevelFilter; diff --git a/src/components/SortableList/SortableList.js b/src/components/SortableList/SortableList.js index 6ab598626..cdb518679 100644 --- a/src/components/SortableList/SortableList.js +++ b/src/components/SortableList/SortableList.js @@ -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, @@ -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, diff --git a/src/components/TitleInformation/TitleInformation.js b/src/components/TitleInformation/TitleInformation.js index fba65c0fe..3730b2888 100644 --- a/src/components/TitleInformation/TitleInformation.js +++ b/src/components/TitleInformation/TitleInformation.js @@ -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, }, @@ -95,14 +95,6 @@ const TitleInformation = (props) => { ); }; -TitleInformation.defaultProps = { - contributors: [], - publications: [], - editions: [], - identifiers: [], - titleLevelRequestsLink: true, -}; - TitleInformation.propTypes = { titleLevelRequestsLink: PropTypes.bool, titleLevelRequestsCount: PropTypes.number.isRequired,