Skip to content

Commit

Permalink
Update examples to use react-jsx (remix-run#10515)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 authored May 22, 2023
1 parent edf6dca commit af334b6
Show file tree
Hide file tree
Showing 61 changed files with 106 additions and 112 deletions.
4 changes: 2 additions & 2 deletions docs/guides/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Once we've sent the HTML back to the browser, we'll need to "hydrate" the applic

```jsx filename=entry-client.jsx lines=[10-15]
import * as React from "react";
import ReactDOM from "react-dom/client";
import * as ReactDOM from "react-dom/client";
import {
createBrowserRouter,
RouterProvider,
Expand Down Expand Up @@ -275,7 +275,7 @@ app.listen(3000);
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`.
```js filename=client.entry.js
import ReactDOM from "react-dom";
import * as ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import App from "./App";

Expand Down
8 changes: 4 additions & 4 deletions docs/start/_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Actually, that "!" doesn't look boring at all. This is pretty exciting. We sat o
Finally, go make sure `index.js` or `main.jsx` (depending on the bundler you used) is actually boring:

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

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

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

Expand Down Expand Up @@ -177,7 +177,7 @@ export default function Invoices() {
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`.

```tsx lines=[2,4-5,8-9,15-21] filename=src/main.jsx
import ReactDOM from "react-dom/client";
import * as ReactDOM from "react-dom/client";
import {
BrowserRouter,
Routes,
Expand Down Expand Up @@ -217,7 +217,7 @@ Let's get some automatic, persistent layout handling by doing just two things:
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:

```jsx lines=[17-20] filename=src/main.jsx
import ReactDOM from "react-dom/client";
import * as ReactDOM from "react-dom/client";
import {
BrowserRouter,
Routes,
Expand Down
2 changes: 1 addition & 1 deletion docs/start/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This enables faster user experiences because the browser doesn't need to request
Client side routing is enabled by creating a `Router` and linking/submitting to pages with `Link` and `<Form>`:

```jsx [10,16,27]
import React from "react";
import * as React from "react";
import { createRoot } from "react-dom/client";
import {
createBrowserRouter,
Expand Down
4 changes: 2 additions & 2 deletions docs/start/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ The `main.jsx` file is the entry point. Open it up and we'll put React Router on
👉 **Create and render a [browser router][createbrowserrouter] in `main.jsx`**

```jsx lines=[3-6,9-14,18] filename=src/main.jsx
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import {
createBrowserRouter,
RouterProvider,
Expand Down
4 changes: 2 additions & 2 deletions examples/auth/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
3 changes: 2 additions & 1 deletion examples/auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
}
1 change: 0 additions & 1 deletion examples/basic-data-router/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import {
createBrowserRouter,
RouterProvider,
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-data-router/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import App from "./app";

ReactDOM.createRoot(document.getElementById("root")!).render(
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-data-router/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
1 change: 0 additions & 1 deletion examples/basic/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { Routes, Route, Outlet, Link } from "react-router-dom";

export default function App() {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-filter-link/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-filter-link/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
1 change: 0 additions & 1 deletion examples/custom-link/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import {
Routes,
Route,
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-link/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-link/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-query-parsing/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
6 changes: 3 additions & 3 deletions examples/custom-query-parsing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"include": ["src", "types"],
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
Expand All @@ -15,7 +14,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
}
},
"include": ["./src", "./types"],
}
2 changes: 1 addition & 1 deletion examples/data-router/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import * as React from "react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router-dom";
import {
Await,
Expand Down
4 changes: 2 additions & 2 deletions examples/data-router/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import App from "./app";

ReactDOM.createRoot(document.getElementById("root")).render(
Expand Down
2 changes: 1 addition & 1 deletion examples/data-router/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
1 change: 0 additions & 1 deletion examples/error-boundaries/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { createBrowserRouter, Outlet, RouterProvider } from "react-router-dom";

import "./index.css";
Expand Down
4 changes: 2 additions & 2 deletions examples/error-boundaries/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";

import App from "./app";

Expand Down
2 changes: 0 additions & 2 deletions examples/error-boundaries/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from "react";

import type { LoaderFunctionArgs } from "react-router-dom";
import {
isRouteErrorResponse,
Expand Down
2 changes: 1 addition & 1 deletion examples/error-boundaries/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
1 change: 0 additions & 1 deletion examples/lazy-loading-router-provider/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import {
Outlet,
Link,
Expand Down
4 changes: 2 additions & 2 deletions examples/lazy-loading-router-provider/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";

import "./index.css";
import App from "./App";
Expand Down
1 change: 0 additions & 1 deletion examples/lazy-loading-router-provider/src/pages/About.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { useLoaderData } from "react-router-dom";

export async function loader() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { Outlet, Link, useLoaderData } from "react-router-dom";

export function DashboardLayout() {
Expand Down
2 changes: 1 addition & 1 deletion examples/lazy-loading-router-provider/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
4 changes: 2 additions & 2 deletions examples/lazy-loading/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import * as React from "react";
import * as ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";

import "./index.css";
Expand Down
2 changes: 0 additions & 2 deletions examples/lazy-loading/src/pages/About.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from "react";

function AboutPage() {
return (
<div>
Expand Down
1 change: 0 additions & 1 deletion examples/lazy-loading/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { Routes, Route, Outlet, Link } from "react-router-dom";

export default function Dashboard() {
Expand Down
2 changes: 1 addition & 1 deletion examples/lazy-loading/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"importsNotUsedAsValues": "error"
},
"include": ["./src"]
Expand Down
Loading

0 comments on commit af334b6

Please sign in to comment.