-
Notifications
You must be signed in to change notification settings - Fork 231
Support React 18 #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support React 18 #655
Changes from 16 commits
9172654
6456f4a
0d82a5f
81db73a
1f0bf1d
3cc6f2e
15347e5
25cfd74
668088b
8fa0041
c95ef45
00526a8
c060620
d4ba70c
2b4a770
ea9d4f9
274932b
9f296b1
07041f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ | |
"scripts": { | ||
"setup": "npm install && npm run validate -s", | ||
"validate": "kcd-scripts validate", | ||
"prepare": "npm run build", | ||
|
||
"build": "kcd-scripts build --out-dir lib && npm run generate:submodules", | ||
"generate:submodules": "ts-node scripts/generate-submodules.ts", | ||
"test": "kcd-scripts test", | ||
|
@@ -43,7 +42,9 @@ | |
"coverage": "codecov", | ||
"docs:dev": "docz dev", | ||
"docs:build": "docz build", | ||
"contributors:add": "all-contributors add" | ||
"contributors:add": "all-contributors add", | ||
"install-16": "npm install --save-dev react@\"^16.9.0\" react-dom@\"^16.9.0\" react-test-renderer@\"^16.9.0\"", | ||
"install-next": "npm install --save-dev react@next react-dom@next react-test-renderer@next" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.12.5", | ||
|
@@ -64,7 +65,7 @@ | |
"kcd-scripts": "11.2.0", | ||
"prettier": "^2.2.1", | ||
"react": "17.0.2", | ||
"react-dom": "^17.0.1", | ||
"react-dom": "17.0.2", | ||
"react-test-renderer": "17.0.2", | ||
"ts-node": "^10.0.0", | ||
"typescript": "4.3.5" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as ReactDOM from 'react-dom' | ||
import * as React from 'react' | ||
|
||
/* istanbul ignore next */ | ||
function createLegacyRoot(container: Element): ReactDOM.Root { | ||
return { | ||
render(element: React.ReactElement) { | ||
ReactDOM.render(element, container) | ||
}, | ||
unmount() { | ||
ReactDOM.unmountComponentAtNode(container) | ||
} | ||
} | ||
} | ||
|
||
/* istanbul ignore next */ | ||
export function createRoot(container: Element) { | ||
return (ReactDOM.createRoot ? ReactDOM.createRoot : createLegacyRoot)(container) | ||
} | ||
|
||
/* istanbul ignore next */ | ||
export function hydrateLegacyRoot(container: Element, element: React.ReactElement): ReactDOM.Root { | ||
ReactDOM.hydrate(element, container) | ||
return createLegacyRoot(container) | ||
} | ||
|
||
/* istanbul ignore next */ | ||
export function hydrateRoot(container: Element, element: React.ReactElement) { | ||
return (ReactDOM.hydrateRoot ? ReactDOM.hydrateRoot : hydrateLegacyRoot)(container, element) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"extends": "./node_modules/kcd-scripts/shared-tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ES6" | ||
"target": "ES6", | ||
"types": ["node", "jest", "react/next", "react-dom/next"] | ||
} | ||
} |