Skip to content

Commit 9163cba

Browse files
refactor: Replace of injectIntl with useIntl
1 parent ec800dd commit 9163cba

File tree

4 files changed

+26
-33
lines changed

4 files changed

+26
-33
lines changed

src/components/FilterBar.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo, useState } from 'react';
1+
import { useCallback, useMemo, useState } from 'react';
22
import PropTypes from 'prop-types';
33

44
import {
@@ -8,7 +8,7 @@ import { Tune } from '@openedx/paragon/icons';
88
import { capitalize, toString } from 'lodash';
99
import { useSelector } from 'react-redux';
1010

11-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
11+
import { useIntl } from '@edx/frontend-platform/i18n';
1212

1313
import {
1414
PostsStatusFilter, RequestStatus,
@@ -19,12 +19,12 @@ import messages from '../discussions/posts/post-filter-bar/messages';
1919
import { ActionItem } from '../discussions/posts/post-filter-bar/PostFilterBar';
2020

2121
const FilterBar = ({
22-
intl,
2322
filters,
2423
selectedFilters,
2524
onFilterChange,
2625
showCohortsFilter,
2726
}) => {
27+
const intl = useIntl();
2828
const [isOpen, setOpen] = useState(false);
2929
const cohorts = useSelector(selectCourseCohorts);
3030
const { status } = useSelector(state => state.cohorts);
@@ -192,7 +192,6 @@ const FilterBar = ({
192192
};
193193

194194
FilterBar.propTypes = {
195-
intl: intlShape.isRequired,
196195
filters: PropTypes.arrayOf(PropTypes.shape({
197196
name: PropTypes.string,
198197
filters: PropTypes.arrayOf(PropTypes.string),
@@ -211,4 +210,4 @@ FilterBar.defaultProps = {
211210
showCohortsFilter: false,
212211
};
213212

214-
export default injectIntl(FilterBar);
213+
export default FilterBar;

src/components/Head/Head.jsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import React from 'react';
2-
31
import { Helmet } from 'react-helmet';
42

53
import { getConfig } from '@edx/frontend-platform';
6-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
75

86
import messages from './messages';
97

10-
const Head = ({ intl }) => (
11-
<Helmet>
12-
<title>
13-
{intl.formatMessage(messages['discussions.page.title'], { siteName: getConfig().SITE_NAME })}
14-
</title>
15-
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" />
16-
</Helmet>
17-
);
8+
const Head = () => {
9+
const intl = useIntl();
1810

19-
Head.propTypes = {
20-
intl: intlShape.isRequired,
11+
return (
12+
<Helmet>
13+
<title>
14+
{intl.formatMessage(messages['discussions.page.title'], { siteName: getConfig().SITE_NAME })}
15+
</title>
16+
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" />
17+
</Helmet>
18+
);
2119
};
2220

23-
export default injectIntl(Head);
21+
export default Head;

src/discussions/in-context-topics/components/BackButton.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import React from 'react';
21
import PropTypes from 'prop-types';
32

43
import { Icon, IconButton, Spinner } from '@openedx/paragon';
54
import { ArrowBack } from '@openedx/paragon/icons';
65
import { useNavigate } from 'react-router-dom';
76

8-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
7+
import { useIntl } from '@edx/frontend-platform/i18n';
98

109
import messages from '../messages';
1110

1211
const BackButton = ({
13-
intl, path, title, loading,
12+
path,
13+
title,
14+
loading,
1415
}) => {
16+
const intl = useIntl();
1517
const navigate = useNavigate();
1618

1719
return (
@@ -35,7 +37,6 @@ const BackButton = ({
3537
};
3638

3739
BackButton.propTypes = {
38-
intl: intlShape.isRequired,
3940
path: PropTypes.shape({}).isRequired,
4041
title: PropTypes.string.isRequired,
4142
loading: PropTypes.bool,
@@ -45,4 +46,4 @@ BackButton.defaultProps = {
4546
loading: false,
4647
};
4748

48-
export default injectIntl(BackButton);
49+
export default BackButton;
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import React from 'react';
2-
31
import { SearchField } from '@openedx/paragon';
42
import { useDispatch } from 'react-redux';
53

6-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
75

86
import { setFilter } from '../data';
97
import messages from '../messages';
108

11-
const TopicSearchResultBar = ({ intl }) => {
9+
const TopicSearchResultBar = () => {
10+
const intl = useIntl();
1211
const dispatch = useDispatch();
1312

1413
return (
@@ -23,8 +22,4 @@ const TopicSearchResultBar = ({ intl }) => {
2322
);
2423
};
2524

26-
TopicSearchResultBar.propTypes = {
27-
intl: intlShape.isRequired,
28-
};
29-
30-
export default injectIntl(TopicSearchResultBar);
25+
export default TopicSearchResultBar;

0 commit comments

Comments
 (0)