mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-31 15:29:32 +02:00
revert react 18
This commit is contained in:
parent
44aa476f04
commit
2ee657bc1e
1 changed files with 44 additions and 45 deletions
|
@ -5,48 +5,47 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import {BrowserRouter} from 'react-router-dom';
|
import {BrowserRouter} from 'react-router-dom';
|
||||||
import {HelmetProvider} from 'react-helmet-async';
|
import {HelmetProvider} from 'react-helmet-async';
|
||||||
|
|
||||||
import ExecutionEnvironment from './exports/ExecutionEnvironment';
|
import ExecutionEnvironment from './exports/ExecutionEnvironment';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import preload from './preload';
|
import preload from './preload';
|
||||||
import docusaurus from './docusaurus';
|
import docusaurus from './docusaurus';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface NodeModule {
|
interface NodeModule {
|
||||||
hot?: {accept: () => void};
|
hot?: {accept: () => void};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client-side render (e.g: running in browser) to become single-page
|
// Client-side render (e.g: running in browser) to become single-page
|
||||||
// application (SPA).
|
// application (SPA).
|
||||||
if (ExecutionEnvironment.canUseDOM) {
|
if (ExecutionEnvironment.canUseDOM) {
|
||||||
window.docusaurus = docusaurus;
|
window.docusaurus = docusaurus;
|
||||||
// For production, attempt to hydrate existing markup for performant
|
// For production, attempt to hydrate existing markup for performant
|
||||||
// first-load experience.
|
// first-load experience.
|
||||||
// For development, there is no existing markup so we had to render it.
|
// For development, there is no existing markup so we had to render it.
|
||||||
// We also preload async component to avoid first-load loading screen.
|
// We also preload async component to avoid first-load loading screen.
|
||||||
const renderMethod =
|
const renderMethod =
|
||||||
process.env.NODE_ENV === 'production' ? ReactDOM.hydrate : ReactDOM.render;
|
process.env.NODE_ENV === 'production' ? ReactDOM.hydrate : ReactDOM.render;
|
||||||
preload(window.location.pathname).then(() => {
|
preload(window.location.pathname).then(() => {
|
||||||
renderMethod(
|
renderMethod(
|
||||||
<HelmetProvider>
|
<HelmetProvider>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<App />
|
<App />
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</HelmetProvider>,
|
</HelmetProvider>,
|
||||||
document.getElementById('__docusaurus'),
|
document.getElementById('__docusaurus'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Webpack Hot Module Replacement API
|
// Webpack Hot Module Replacement API
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
// Self-accepting method/ trick
|
// Self-accepting method/ trick
|
||||||
// (https://github.com/webpack/webpack-dev-server/issues/100#issuecomment-290911036)
|
// (https://github.com/webpack/webpack-dev-server/issues/100#issuecomment-290911036)
|
||||||
module.hot.accept();
|
module.hot.accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue