-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust container prop for react 18 (#109)
- Loading branch information
Showing
8 changed files
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import ReactDOM from 'react-dom'; | ||
|
||
export function reactDomRender(CustomReactDOM, element, target) { | ||
const ResolvedReactDOM = CustomReactDOM || ReactDOM; | ||
const createRoot = ResolvedReactDOM.createRoot; // React 18+ | ||
export function reactDomRender(createRoot, element, target) { | ||
// React 18+ | ||
if (createRoot) { | ||
const root = createRoot(target); | ||
root.render(element); | ||
return root; | ||
} else { | ||
ResolvedReactDOM.render(element, target); | ||
ReactDOM.render(element, target); | ||
} | ||
} | ||
|
||
export function reactDomUnmount(CustomReactDOM, root, target) { | ||
export function reactDomUnmount(root, target) { | ||
if (root) root.unmount(); | ||
else (CustomReactDOM || ReactDOM).unmountComponentAtNode(target); | ||
else ReactDOM.unmountComponentAtNode(target); | ||
} |