From fe6e61be0b1cc03b2b3cb7e16bbc1441e9259628 Mon Sep 17 00:00:00 2001 From: David Glick Date: Wed, 18 Dec 2024 14:35:03 -0800 Subject: [PATCH] Use useIntl instead of injectIntl --- .../theme/RelatedItems/RelatedItems.jsx | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/volto/src/components/theme/RelatedItems/RelatedItems.jsx b/packages/volto/src/components/theme/RelatedItems/RelatedItems.jsx index e854d5d7c9..e0e121c377 100644 --- a/packages/volto/src/components/theme/RelatedItems/RelatedItems.jsx +++ b/packages/volto/src/components/theme/RelatedItems/RelatedItems.jsx @@ -4,7 +4,7 @@ */ import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink'; -import { defineMessages, injectIntl } from 'react-intl'; +import { defineMessages, useIntl } from 'react-intl'; import PropTypes from 'prop-types'; import { Container } from 'semantic-ui-react'; import config from '@plone/volto/registry'; @@ -22,7 +22,8 @@ const messages = defineMessages({ * @param {array} relatedItems Array of related items. * @returns {JSX.Element} Markup of the component. */ -const RelatedItems = ({ content, intl }) => { +const RelatedItems = ({ content }) => { + const intl = useIntl(); const relatedItems = content?.relatedItems; if ( !config.settings.showRelatedItems || @@ -56,22 +57,14 @@ const RelatedItems = ({ content, intl }) => { * @static */ RelatedItems.propTypes = { - relatedItems: PropTypes.arrayOf( - PropTypes.shape({ - '@id': PropTypes.string.isRequired, - title: PropTypes.string.isRequired, - }), - ), - intl: PropTypes.object.isRequired, + content: PropTypes.shape({ + relatedItems: PropTypes.arrayOf( + PropTypes.shape({ + '@id': PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + }), + ), + }), }; -/** - * Default properties. - * @property {Object} defaultProps Default properties. - * @static - */ -RelatedItems.defaultProps = { - relatedItems: [], -}; - -export default injectIntl(RelatedItems); +export default RelatedItems;