Skip to content

Commit 4c967d1

Browse files
maltheismlaemtl
andauthored
[package.json] Upgrade react to version 18 (#8188)
Upgrades react to version 18 and upgrade to latest rendering of react. Co-authored-by: Laetitia Fesselier <laetitia.fesselier@mail.mcgill.ca>
1 parent de56976 commit 4c967d1

File tree

59 files changed

+2200
-14921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2200
-14921
lines changed

htdocs/js/helpHandler.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@ $(document).ready(function() {
3838
// Render Markdown in wrap div.
3939
// If help content is from Markdown helpfile.
4040
if (content.format === 'markdown') {
41-
ReactDOM.render(RMarkdown({content: content.content}), wrap);
41+
const root = ReactDOM.createRoot(wrap);
42+
root.render(RMarkdown({content: content.content}));
4243
} else {
4344
// If help content is from DB.
4445
wrap.innerHTML = '<hr id=\'help-separator\'>';
4546
if (content.topic) {
4647
wrap.innerHTML = '<h3>' + content.topic + '</h3>';
4748
}
48-
ReactDOM.render(
49-
RMarkdown({content: content.content}),
50-
markdownContent
51-
);
49+
const root = ReactDOM.createRoot(markdownContent);
50+
root.render(RMarkdown({content: content.content}));
5251
wrap.appendChild(markdownContent);
5352
if (content.updated) {
5453
wrap.innerHTML = wrap.innerHTML

modules/acknowledgements/jsx/acknowledgementsIndex.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {createRoot} from 'react-dom/client';
12
import React, {Component} from 'react';
23
import PropTypes from 'prop-types';
34

@@ -455,12 +456,14 @@ AcknowledgementsIndex.propTypes = {
455456
};
456457

457458
window.addEventListener('load', () => {
458-
ReactDOM.render(
459+
const root = createRoot(
460+
document.getElementById('lorisworkspace')
461+
);
462+
root.render(
459463
<AcknowledgementsIndex
460464
dataURL={`${loris.BaseURL}/acknowledgements/?format=json`}
461465
submitURL={`${loris.BaseURL}/acknowledgements/`}
462466
hasPermission={loris.userHasPermission}
463-
/>,
464-
document.getElementById('lorisworkspace')
467+
/>
465468
);
466469
});

modules/battery_manager/jsx/batteryManagerIndex.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {createRoot} from 'react-dom/client';
12
import React, {Component} from 'react';
23
import PropTypes from 'prop-types';
34

@@ -501,12 +502,12 @@ BatteryManagerIndex.propTypes = {
501502
};
502503

503504
window.addEventListener('load', () => {
504-
ReactDOM.render(
505+
const root = createRoot(document.getElementById('lorisworkspace'));
506+
root.render(
505507
<BatteryManagerIndex
506508
testEndpoint={`${loris.BaseURL}/battery_manager/testendpoint/`}
507509
optionEndpoint={`${loris.BaseURL}/battery_manager/testoptionsendpoint`}
508510
hasPermission={loris.userHasPermission}
509-
/>,
510-
document.getElementById('lorisworkspace')
511+
/>
511512
);
512513
});

modules/behavioural_qc/jsx/behaviouralQCIndex.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {createRoot} from 'react-dom/client';
12
import React from 'react';
23
import PropTypes from 'prop-types';
34
import {TabPane, Tabs} from 'jsx/Tabs';
@@ -50,10 +51,10 @@ BehaviouralQC.propTypes = {
5051
* Render Behavioural Quality Control on page load.
5152
*/
5253
window.addEventListener('load', () => {
53-
ReactDOM.render(
54+
const root = createRoot(document.getElementById('lorisworkspace'));
55+
root.render(
5456
<BehaviouralQC
5557
baseURL={loris.BaseURL}
56-
/>,
57-
document.getElementById('lorisworkspace')
58+
/>
5859
);
5960
});

modules/brainbrowser/templates/form_brainbrowser.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,6 @@
181181

182182
<script>
183183
var brainBrowserPage = RBrainBrowser();
184-
ReactDOM.render(brainBrowserPage, document.getElementById('brainbrowserPage'));
184+
const root = ReactDOM.createRoot(document.getElementById('brainbrowserPage'));
185+
root.render(brainBrowserPage);
185186
</script>

modules/candidate_list/jsx/candidateListIndex.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {createRoot} from 'react-dom/client';
12
import React, {Component} from 'react';
23
import PropTypes from 'prop-types';
34

@@ -383,13 +384,13 @@ CandidateListIndex.propTypes = {
383384

384385
window.addEventListener('load', () => {
385386
const args = QueryString.get();
386-
ReactDOM.render(
387+
const root = createRoot(document.getElementById('lorisworkspace'));
388+
root.render(
387389
<CandidateListIndex
388390
dataURL={`${loris.BaseURL}/candidate_list/?format=json`}
389391
hasPermission={loris.userHasPermission}
390392
baseURL={loris.BaseURL}
391393
betaProfileLink={args['betaprofile']}
392-
/>,
393-
document.getElementById('lorisworkspace')
394+
/>
394395
);
395396
});
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/* global formatColumn */
22

3+
import {createRoot} from 'react-dom/client';
4+
import React from 'react';
5+
36
document.addEventListener('DOMContentLoaded', () => {
4-
ReactDOM.render(<DynamicDataTable
5-
DataURL={`${loris.BaseURL}/candidate_list/?format=json`}
6-
getFormattedCell={formatColumn}
7-
freezeColumn="PSCID"
8-
/>,
9-
document.getElementById('datatable')
7+
const root = createRoot(document.getElementById('datatable'));
8+
root.render(
9+
<DynamicDataTable
10+
DataURL={`${loris.BaseURL}/candidate_list/?format=json`}
11+
getFormattedCell={formatColumn}
12+
freezeColumn="PSCID"
13+
/>
1014
);
1115
});

modules/candidate_parameters/jsx/CandidateParameters.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {createRoot} from 'react-dom/client';
12
import React, {Component} from 'react';
23
import PropTypes from 'prop-types';
34
import CandidateInfo from './CandidateInfo';
@@ -130,18 +131,14 @@ CandidateParameters.propTypes = {
130131
const args = QueryString.get(document.currentScript.src);
131132

132133
window.addEventListener('load', () => {
133-
const candidateParameters = (
134+
const root = createRoot(document.getElementById('lorisworkspace'));
135+
root.render(
134136
<div className="page-candidate-parameters">
135137
<CandidateParameters
136138
Module="candidate_parameters"
137139
candID={args.candID}
138140
/>
139141
</div>
140142
);
141-
142-
ReactDOM.render(
143-
candidateParameters,
144-
document.getElementById('lorisworkspace')
145-
);
146143
});
147144

modules/candidate_profile/templates/form_candidate_profile.tpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ window.addEventListener('load', () => {
7474
}
7575
7676
function displayCards(cards) {
77-
ReactDOM.render(
77+
const root = ReactDOM.createRoot(
78+
document.getElementById('candidatedashboard')
79+
);
80+
root.render(
7881
React.createElement(
7982
lorisjs.CSSGrid.default,
8083
{ Cards: cards }
81-
),
82-
document.getElementById('candidatedashboard')
84+
)
8385
);
8486
}
8587

0 commit comments

Comments
 (0)