Skip to content

Commit af334b6

Browse files
authored
Update examples to use react-jsx (#10515)
1 parent edf6dca commit af334b6

File tree

61 files changed

+106
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+106
-112
lines changed

docs/guides/ssr.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Once we've sent the HTML back to the browser, we'll need to "hydrate" the applic
143143

144144
```jsx filename=entry-client.jsx lines=[10-15]
145145
import * as React from "react";
146-
import ReactDOM from "react-dom/client";
146+
import * as ReactDOM from "react-dom/client";
147147
import {
148148
createBrowserRouter,
149149
RouterProvider,
@@ -275,7 +275,7 @@ app.listen(3000);
275275
And finally, you'll need a similar file to "hydrate" the app with your JavaScript bundle that includes the very same `App` component. Note the use of `BrowserRouter` instead of `StaticRouter`.
276276
277277
```js filename=client.entry.js
278-
import ReactDOM from "react-dom";
278+
import * as ReactDOM from "react-dom";
279279
import { BrowserRouter } from "react-router-dom";
280280
import App from "./App";
281281

docs/start/_tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Actually, that "!" doesn't look boring at all. This is pretty exciting. We sat o
7474
Finally, go make sure `index.js` or `main.jsx` (depending on the bundler you used) is actually boring:
7575

7676
```tsx filename=src/main.jsx
77-
import ReactDOM from "react-dom/client";
77+
import * as ReactDOM from "react-dom/client";
7878
import App from "./App";
7979

8080
const root = ReactDOM.createRoot(
@@ -98,7 +98,7 @@ npm run dev
9898
First things first, we want to connect your app to the browser's URL: import `BrowserRouter` and render it around your whole app.
9999

100100
```tsx lines=[2,9-11] filename=src/main.jsx
101-
import ReactDOM from "react-dom/client";
101+
import * as ReactDOM from "react-dom/client";
102102
import { BrowserRouter } from "react-router-dom";
103103
import App from "./App";
104104

@@ -177,7 +177,7 @@ export default function Invoices() {
177177
Finally, let's teach React Router how to render our app at different URLs by creating our first "Route Config" inside of `main.jsx` or `index.js`.
178178

179179
```tsx lines=[2,4-5,8-9,15-21] filename=src/main.jsx
180-
import ReactDOM from "react-dom/client";
180+
import * as ReactDOM from "react-dom/client";
181181
import {
182182
BrowserRouter,
183183
Routes,
@@ -217,7 +217,7 @@ Let's get some automatic, persistent layout handling by doing just two things:
217217
First let's nest the routes. Right now the expenses and invoices routes are siblings to the app, we want to make them _children_ of the app route:
218218

219219
```jsx lines=[17-20] filename=src/main.jsx
220-
import ReactDOM from "react-dom/client";
220+
import * as ReactDOM from "react-dom/client";
221221
import {
222222
BrowserRouter,
223223
Routes,

docs/start/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This enables faster user experiences because the browser doesn't need to request
1818
Client side routing is enabled by creating a `Router` and linking/submitting to pages with `Link` and `<Form>`:
1919

2020
```jsx [10,16,27]
21-
import React from "react";
21+
import * as React from "react";
2222
import { createRoot } from "react-dom/client";
2323
import {
2424
createBrowserRouter,

docs/start/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ The `main.jsx` file is the entry point. Open it up and we'll put React Router on
6868
👉 **Create and render a [browser router][createbrowserrouter] in `main.jsx`**
6969

7070
```jsx lines=[3-6,9-14,18] filename=src/main.jsx
71-
import React from "react";
72-
import ReactDOM from "react-dom/client";
71+
import * as React from "react";
72+
import * as ReactDOM from "react-dom/client";
7373
import {
7474
createBrowserRouter,
7575
RouterProvider,

examples/auth/src/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom/client";
1+
import * as React from "react";
2+
import * as ReactDOM from "react-dom/client";
33
import { BrowserRouter } from "react-router-dom";
44

55
import "./index.css";

examples/auth/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react"
17+
"jsx": "react-jsx",
18+
"importsNotUsedAsValues": "error"
1819
},
1920
"include": ["./src"]
2021
}

examples/basic-data-router/src/app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import {
32
createBrowserRouter,
43
RouterProvider,

examples/basic-data-router/src/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom/client";
1+
import * as React from "react";
2+
import * as ReactDOM from "react-dom/client";
33
import App from "./app";
44

55
ReactDOM.createRoot(document.getElementById("root")!).render(

examples/basic-data-router/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react",
17+
"jsx": "react-jsx",
1818
"importsNotUsedAsValues": "error"
1919
},
2020
"include": ["./src"]

examples/basic/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from "react";
21
import { Routes, Route, Outlet, Link } from "react-router-dom";
32

43
export default function App() {

0 commit comments

Comments
 (0)