Skip to content

Commit b3d4060

Browse files
committed
dep: replace react-loadable by lazy and suspense
fixes #1009 `react-loadable` is a 7 years old package that uses a legacy contextTypes API, removed in React 19. The same component behavior can be achieved by using React's `lazy` and `Suspense` functionalities instead. This affects the `InterviewsByAccessCode` component.
1 parent b56101a commit b3d4060

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

packages/evolution-frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"react-dom": "^19.0.0",
6161
"react-i18next": "^12.3.1",
6262
"react-input-range": "^1.3.0",
63-
"react-loadable": "^5.5.0",
6463
"react-markdown": "^9.0.1",
6564
"react-modal": "^3.16.1",
6665
"react-redux": "^9.2.0",

packages/evolution-frontend/src/components/admin/interviews/InterviewsByAccessCode.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@
44
* This file is licensed under the MIT License.
55
* License text available at https://opensource.org/licenses/MIT
66
*/
7-
import React from 'react';
7+
import React, { lazy, Suspense } from 'react';
88
import { useTranslation } from 'react-i18next';
9-
import Loadable from 'react-loadable';
109
import Loader from 'react-spinners/HashLoader';
1110

1211
import { InterviewContext } from '../../../contexts/InterviewContext';
1312
import InputString from 'chaire-lib-frontend/lib/components/input/InputString';
1413
import { Link, useLocation, useParams } from 'react-router';
1514
import { _booleish } from 'chaire-lib-common/lib/utils/LodashExtensions';
1615

17-
const loader = function Loading() {
18-
return <Loader size={30} color={'#aaaaaa'} loading={true} />;
19-
};
16+
const LoaderComponent = () => <Loader size={30} color={'#aaaaaa'} loading={true} />;
2017

21-
const InterviewsComponent = Loadable({
22-
// TODO: move this to componentDidMount like in Monitoring.tsx
23-
loader: () => import('./InterviewSearchList'),
24-
loading: loader
25-
});
18+
const InterviewsComponent = lazy(() => import('./InterviewSearchList'));
2619

2720
const InterviewsByAccessCode: React.FC = () => {
2821
const location = useLocation();
@@ -54,7 +47,9 @@ const InterviewsByAccessCode: React.FC = () => {
5447
</button>
5548
</Link>
5649
</div>
57-
<InterviewsComponent autoCreateIfNoData={createNewIfNoData} queryData={urlSearch} />
50+
<Suspense fallback={<LoaderComponent />}>
51+
<InterviewsComponent autoCreateIfNoData={createNewIfNoData} queryData={urlSearch} />
52+
</Suspense>
5853
</div>
5954
);
6055
};

yarn.lock

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11136,7 +11136,7 @@ prompts@^2.0.1:
1113611136
kleur "^3.0.3"
1113711137
sisteransi "^1.0.4"
1113811138

11139-
prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
11139+
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
1114011140
version "15.8.1"
1114111141
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
1114211142
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -11366,13 +11366,6 @@ react-lifecycles-compat@^3.0.0:
1136611366
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
1136711367
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
1136811368

11369-
react-loadable@^5.5.0:
11370-
version "5.5.0"
11371-
resolved "https://registry.yarnpkg.com/react-loadable/-/react-loadable-5.5.0.tgz#582251679d3da86c32aae2c8e689c59f1196d8c4"
11372-
integrity sha512-C8Aui0ZpMd4KokxRdVAm2bQtI03k2RMRNzOB+IipV3yxFTSVICv7WoUr5L9ALB5BmKO1iHgZtWM8EvYG83otdg==
11373-
dependencies:
11374-
prop-types "^15.5.0"
11375-
1137611369
react-markdown@^9.0.1:
1137711370
version "9.0.1"
1137811371
resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-9.0.1.tgz#c05ddbff67fd3b3f839f8c648e6fb35d022397d1"

0 commit comments

Comments
 (0)