Skip to content

Commit

Permalink
Use useIntl instead of injectIntl
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Dec 18, 2024
1 parent d5ecf7b commit fe6e61b
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions packages/volto/src/components/theme/RelatedItems/RelatedItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 ||
Expand Down Expand Up @@ -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;

0 comments on commit fe6e61b

Please sign in to comment.