updated React templates to use react 18 new root api#1142
updated React templates to use react 18 new root api#1142spaceFitzpa wants to merge 1 commit intojaredpalmer:masterfrom
Conversation
|
Are the |
|
This did not work for me, I got stuck with a
"devDependencies": {
"@babel/core": "^7.18.13",
"@rollup/plugin-image": "^2.1.1",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-url": "^7.0.0",
"@size-limit/preset-small-lib": "^8.0.1",
"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-info": "^5.3.21",
"@storybook/addon-links": "^6.5.10",
"@storybook/addons": "^6.5.10",
"@storybook/react": "^6.5.10",
"@svgr/rollup": "^6.3.1",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"babel-loader": "^8.2.5",
"eslint-plugin-jsx-a11y": "^6.6.1",
"husky": "^8.0.1",
"jest-transform-stub": "^2.0.0",
"pinst": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"size-limit": "^8.0.1",
"tsdx": "^0.14.1",
"tslib": "^2.4.0",
"typescript": "^4.8.2"
}
"jest": {
"moduleNameMapper": {
"^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2|svg|mdx)$": "jest-transform-stub"
},
"globals": {
"IS_REACT_ACT_ENVIRONMENT": true
}
}
{
"name": "example",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "parcel index.html",
"build": "rm -r ./dist | parcel build index.html"
},
"alias": {
"$react-dom": "../node_modules/react-dom/profiling"
},
"devDependencies": {
"parcel": "^2.7.0",
"parcel-bundler": "^1.12.5"
}
}
import * as React from "react"
import { createRoot } from "react-dom/client"
import { Thing } from "../."
const App = () => {
return (
<div>
<Thing />
</div>
)
}
const container = document.getElementById("root")
const root = createRoot(container!)
root.render(<App />)
import React from "react"
import { createRoot } from "react-dom/client"
import { act } from "react-dom/test-utils"
import { Default as Thing } from "../stories/Thing.stories"
describe("Thing", () => {
it("renders without crashing", () => {
const container = document.createElement("div")
const root = createRoot(container!)
act(() => root.render(<Thing />))
})
}) |
reactandreact-with-storybookexample and test files to use React 18's newroot APIReactDOM.render is no longer supported in React 18error.