Upgrade to React 18 (#24916)
This commit is contained in:
parent
4a22e72b9b
commit
8d6aea3326
13 changed files with 127 additions and 148 deletions
|
@ -2,7 +2,7 @@ import './public-path';
|
|||
import { delegate } from '@rails/ujs';
|
||||
import ready from '../mastodon/ready';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
const setAnnouncementEndsAttributes = (target) => {
|
||||
const valid = target?.value && target?.validity?.valid;
|
||||
|
@ -231,11 +231,13 @@ ready(() => {
|
|||
|
||||
import('../mastodon/containers/admin_component').then(({ default: AdminComponent }) => {
|
||||
return import('../mastodon/components/admin/' + componentName).then(({ default: Component }) => {
|
||||
ReactDOM.render((
|
||||
const root = createRoot(element);
|
||||
|
||||
root.render (
|
||||
<AdminComponent locale={locale}>
|
||||
<Component {...componentProps} />
|
||||
</AdminComponent>
|
||||
), element);
|
||||
</AdminComponent>,
|
||||
);
|
||||
});
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
|
|
|
@ -15,7 +15,7 @@ import { delegate } from '@rails/ujs';
|
|||
import emojify from '../mastodon/features/emoji/emoji';
|
||||
import { getLocale } from '../mastodon/locales';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
start();
|
||||
|
@ -153,7 +153,8 @@ function loaded() {
|
|||
|
||||
const content = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
|
||||
const root = createRoot(content);
|
||||
root.render(<MediaContainer locale={locale} components={reactComponents} />);
|
||||
document.body.appendChild(content);
|
||||
scrollToDetailedStatus();
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import { start } from '../mastodon/common';
|
|||
import ready from '../mastodon/ready';
|
||||
import ComposeContainer from '../mastodon/containers/compose_container';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
start();
|
||||
|
||||
|
@ -16,7 +16,8 @@ function loaded() {
|
|||
if(!attr) return;
|
||||
|
||||
const props = JSON.parse(attr);
|
||||
ReactDOM.render(<ComposeContainer {...props} />, mountNode);
|
||||
const root = createRoot(mountNode);
|
||||
root.render(<ComposeContainer {...props} />);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue