-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from kirovboris/react_18
feat: support react 18
- Loading branch information
Showing
39 changed files
with
843 additions
and
1,058 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
clone_depth: 1 | ||
|
||
environment: | ||
NODEJS_VERSION: "12" | ||
NODEJS_VERSION: "14" | ||
|
||
install: | ||
- ps: >- | ||
|
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 |
---|---|---|
|
@@ -52,3 +52,4 @@ lib/* | |
test/data/lib/* | ||
test/data/server-render/.next | ||
package-lock.json | ||
yarn.lock |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*global document*/ | ||
|
||
/*eslint-disable no-unused-vars*/ | ||
function getRootElsReact16to18 (el) { | ||
el = el || document.body; | ||
|
||
let rootEls = []; | ||
|
||
if (el._reactRootContainer) { | ||
const rootContainer = el._reactRootContainer._internalRoot || el._reactRootContainer; | ||
|
||
rootEls.push(rootContainer.current.child); | ||
} | ||
|
||
else { | ||
//NOTE: approach for React 18 createRoot API | ||
for (var prop of Object.keys(el)) { | ||
if (!/^__reactContainer/.test(prop)) continue; | ||
|
||
//NOTE: component and its alternate version has the same stateNode, but stateNode has the link to rendered version in the 'current' field | ||
const component = el[prop].stateNode.current; | ||
|
||
rootEls.push(component); | ||
|
||
break; | ||
} | ||
} | ||
|
||
const children = el.children; | ||
|
||
for (let index = 0; index < children.length; ++index) { | ||
const child = children[index]; | ||
|
||
rootEls = rootEls.concat(getRootElsReact16to18(child)); | ||
|
||
} | ||
|
||
return rootEls; | ||
} |
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
Oops, something went wrong.