Skip to content

Commit

Permalink
UIIN-2890: React v19: refactor away from default props for functional…
Browse files Browse the repository at this point in the history
… components (#2673)
  • Loading branch information
mariia-aloshyna authored Nov 25, 2024
1 parent d1a545f commit 28df52d
Show file tree
Hide file tree
Showing 62 changed files with 291 additions and 608 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 @@
* *BREAKING* Rename quick-marc routes from `bib` to `bibliographic` and `duplicate` to `derive`. Refs UIIN-3120.
* *BREAKING* Provide necessary props for browse lookup facets. Remove the facets state reset functionality. Refs UIIN-3099.
* Add permission for "Share local instance" option on Member tenants. Refs UIIN-3140.
* React v19: refactor away from default props for functional components. Refs UIIN-2890.

## [12.0.3] (IN PROGRESS)

Expand Down
17 changes: 6 additions & 11 deletions src/Instance/HoldingsList/Holding/Holding.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ const Holding = ({
holding,
onViewHolding,
onAddItem,
holdings,
draggable,
droppable,
holdings = [],
draggable = false,
droppable = false,
selectHoldingsForDrag,
isHoldingDragSelected,
isDraggable,
isItemsDroppable,
isDraggable = false,
isItemsDroppable = true,
tenantId,
showViewHoldingsButton,
showAddItemButton,
isBarcodeAsHotlink,
instanceId,
pathToAccordionsState,
pathToAccordionsState = [],
}) => {
return (
<div>
Expand Down Expand Up @@ -94,9 +94,4 @@ Holding.propTypes = {
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

Holding.defaultProps = {
isItemsDroppable: true,
pathToAccordionsState: [],
};

export default Holding;
10 changes: 3 additions & 7 deletions src/Instance/HoldingsList/Holding/HoldingContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const DraggableHolding = ({
showAddItemButton,
isBarcodeAsHotlink,
instanceId,
pathToAccordionsState,
pathToAccordionsState = [],
...rest
}) => {
const rowStyles = useMemo(() => (
Expand Down Expand Up @@ -115,8 +115,6 @@ DraggableHolding.propTypes = {
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

DraggableHolding.defaultProps = { pathToAccordionsState: [] };

const HoldingContainer = ({
location,
history,
Expand All @@ -125,11 +123,11 @@ const HoldingContainer = ({
isBarcodeAsHotlink,
instance,
holding,
isDraggable,
isDraggable = false,
holdingIndex,
draggingHoldingsCount,
tenantId,
pathToAccordionsState,
pathToAccordionsState = [],
...rest
}) => {
const stripes = useStripes();
Expand Down Expand Up @@ -202,6 +200,4 @@ HoldingContainer.propTypes = {
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

HoldingContainer.defaultProps = { pathToAccordionsState: [] };

export default withRouter(HoldingContainer);
13 changes: 4 additions & 9 deletions src/Instance/HoldingsList/HoldingsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { HoldingContainer } from './Holding';

const HoldingsList = ({
instance,
holdings,
holdings = [],
tenantId,
showViewHoldingsButton,
showAddItemButton,
isBarcodeAsHotlink,
pathToAccordionsState,
draggable,
droppable,
pathToAccordionsState = [],
draggable = false,
droppable = false,
}) => holdings.map(holding => (
<HoldingContainer
key={`items_${holding.id}`}
Expand Down Expand Up @@ -41,9 +41,4 @@ HoldingsList.propTypes = {
droppable: PropTypes.bool,
};

HoldingsList.defaultProps = {
holdings: [],
pathToAccordionsState: [],
};

export default HoldingsList;
6 changes: 2 additions & 4 deletions src/Instance/HoldingsList/HoldingsListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { useInstanceHoldingsQuery } from '../../providers';

const HoldingsListContainer = ({
instance,
isHoldingsMove,
tenantId,
pathToAccordionsState,
isHoldingsMove = false,
pathToAccordionsState = [],
...rest
}) => {
const stripes = useStripes();
Expand Down Expand Up @@ -57,6 +57,4 @@ HoldingsListContainer.propTypes = {
pathToAccordionsState: PropTypes.arrayOf(PropTypes.string),
};

HoldingsListContainer.defaultProps = { pathToAccordionsState: [] };

export default HoldingsListContainer;
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import StatisticalCodesList from './StatisticalCodesList';

const InstanceAdministrativeView = ({
id,
instance,
instanceStatuses,
issuanceModes,
statisticalCodes,
statisticalCodeTypes,
instance = {},
instanceStatuses = [],
issuanceModes = [],
statisticalCodes = [],
statisticalCodeTypes = [],
}) => {
const { search } = useLocation();

Expand Down Expand Up @@ -212,12 +212,4 @@ InstanceAdministrativeView.propTypes = {
statisticalCodeTypes: PropTypes.arrayOf(PropTypes.object),
};

InstanceAdministrativeView.defaultProps = {
instance: {},
instanceStatuses: [],
issuanceModes: [],
statisticalCodes: [],
statisticalCodeTypes: [],
};

export default InstanceAdministrativeView;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const columnWidths = {
};

const StatisticalCodesList = ({
statisticalCodes,
statisticalCodes = [],
}) => {
const intl = useIntl();

Expand All @@ -57,8 +57,4 @@ StatisticalCodesList.propTypes = {
statisticalCodes: PropTypes.arrayOf(PropTypes.object),
};

StatisticalCodesList.defaultProps = {
statisticalCodes: [],
};

export default StatisticalCodesList;
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const classificationsRowFormatter = {

const InstanceClassificationView = ({
id,
classifications,
classificationTypes,
classifications = [],
classificationTypes = [],
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -100,9 +100,4 @@ InstanceClassificationView.propTypes = {
classificationTypes: PropTypes.arrayOf(PropTypes.object),
};

InstanceClassificationView.defaultProps = {
classifications: [],
classificationTypes: [],
};

export default InstanceClassificationView;
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const columnWidths = {

const InstanceContributorsView = ({
id,
contributors,
contributorTypes,
contributorNameTypes,
source,
segment,
contributors = [],
contributorTypes = [],
contributorNameTypes = [],
segment = '',
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -103,17 +103,11 @@ const InstanceContributorsView = ({

InstanceContributorsView.propTypes = {
id: PropTypes.string.isRequired,
source: PropTypes.string.isRequired,
contributors: PropTypes.arrayOf(PropTypes.object),
contributorTypes: PropTypes.arrayOf(PropTypes.object),
contributorNameTypes: PropTypes.arrayOf(PropTypes.object),
source: PropTypes.string.isRequired,
segment: PropTypes.string,
};

InstanceContributorsView.defaultProps = {
contributors: [],
contributorTypes: [],
contributorNameTypes: [],
};

export default InstanceContributorsView;
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const columnWidths = {
};

const DescriptiveFormatsList = ({
formats,
resourceFormats,
formats = [],
resourceFormats = [],
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -79,9 +79,4 @@ DescriptiveFormatsList.propTypes = {
resourceFormats: PropTypes.arrayOf(PropTypes.object),
};

DescriptiveFormatsList.defaultProps = {
formats: [],
resourceFormats: [],
};

export default DescriptiveFormatsList;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const columnWidths = {
};

const DescriptivePublicationsList = ({
publications,
publications = [],
}) => {
const intl = useIntl();

Expand All @@ -61,8 +61,4 @@ DescriptivePublicationsList.propTypes = {
publications: PropTypes.arrayOf(PropTypes.object),
};

DescriptivePublicationsList.defaultProps = {
publications: [],
};

export default DescriptivePublicationsList;
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import {

const InstanceDescriptiveView = ({
id,
instance,
resourceTypes,
resourceFormats,
natureOfContentTerms,
instanceDateTypes,
instance = {},
resourceTypes = [],
resourceFormats = [],
natureOfContentTerms = [],
instanceDateTypes = [],
}) => {
const resourceType = useMemo(() => {
return resourceTypes.find(type => type.id === instance.instanceTypeId) || {};
Expand Down Expand Up @@ -169,12 +169,4 @@ InstanceDescriptiveView.propTypes = {
instanceDateTypes: PropTypes.arrayOf(PropTypes.object),
};

InstanceDescriptiveView.defaultProps = {
instance: {},
resourceTypes: [],
resourceFormats: [],
natureOfContentTerms: [],
instanceDateTypes: [],
};

export default InstanceDescriptiveView;
16 changes: 5 additions & 11 deletions src/Instance/InstanceDetails/InstanceDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ const accordions = {

const InstanceDetails = forwardRef(({
children,
instance,
onClose,
actionMenu,
tagsEnabled,
mutateInstance,
userTenantPermissions,
isShared,
instance = {},
userTenantPermissions = [],
tagsEnabled = false,
isShared = false,
...rest
}, ref) => {
const intl = useIntl();
Expand Down Expand Up @@ -316,9 +316,9 @@ const InstanceDetails = forwardRef(({
});

InstanceDetails.propTypes = {
onClose: PropTypes.func.isRequired,
children: PropTypes.node,
actionMenu: PropTypes.func,
onClose: PropTypes.func.isRequired,
mutateInstance: PropTypes.func,
instance: PropTypes.object,
tagsToggle: PropTypes.func,
Expand All @@ -327,10 +327,4 @@ InstanceDetails.propTypes = {
isShared: PropTypes.bool,
};

InstanceDetails.defaultProps = {
instance: {},
tagsEnabled: false,
isShared: false,
};

export default InstanceDetails;
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const getFormatter = (elAccessRelationshipsMap) => ({

const InstanceElecAccessView = ({
id,
electronicAccessLines,
electronicAccessRelationships,
electronicAccessLines = [],
electronicAccessRelationships = [],
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -101,9 +101,4 @@ InstanceElecAccessView.propTypes = {
electronicAccessRelationships: PropTypes.arrayOf(PropTypes.object),
};

InstanceElecAccessView.defaultProps = {
electronicAccessLines: [],
electronicAccessRelationships: [],
};

export default InstanceElecAccessView;
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const formatter = {

const InstanceIdentifiersView = ({
id,
identifiers,
identifierTypes,
identifiers = [],
identifierTypes = [],
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -87,9 +87,4 @@ InstanceIdentifiersView.propTypes = {
identifierTypes: PropTypes.arrayOf(PropTypes.object),
};

InstanceIdentifiersView.defaultProps = {
identifiers: [],
identifierTypes: [],
};

export default InstanceIdentifiersView;
Loading

0 comments on commit 28df52d

Please sign in to comment.