Skip to content

Commit

Permalink
Fixed initial rendering
Browse files Browse the repository at this point in the history
When using React 18+, the app must be rendered using createRoot.
  • Loading branch information
felixgirault committed Sep 13, 2024
1 parent c7152e3 commit dc28fdd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"uneval.js": "^5.7.2"
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": ">=16.8"
"react": ">=18",
"react-dom": ">=18"
}
}
9 changes: 4 additions & 5 deletions src/ui/setup.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import React, {createRef} from 'react';
import {render} from 'react-dom';
import {createRoot} from 'react-dom/client';
import {Manager} from '../core';
import Context from './components/Context';
import Main, {MainHandle} from './components/Main';
import type {Config} from './types';
import {getRootElement} from './utils/dom';
import {once} from './utils/functions';
import {Manager} from '../core';

export default (config: Config, manager: Manager) => {
const element = getRootElement(config.orejimeElement);
const appRef = createRef<MainHandle>();
const show = once(() => {
render(
createRoot(element).render(
<Context.Provider
value={{
config,
manager
}}
>
<Main ref={appRef} />
</Context.Provider>,
element
</Context.Provider>
);
});

Expand Down

0 comments on commit dc28fdd

Please sign in to comment.