Skip to content
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

chore: upgrade core packages to react-18 #3917

Merged
merged 6 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-cars-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/react": patch
---

React 18 gets more strict with types, this adds a runtime cast to a string for the `<title>` tag value.
2 changes: 1 addition & 1 deletion examples/blog-tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@testing-library/cypress": "^8.0.2",
"@testing-library/dom": "^8.13.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^12.1.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/eslint": "^8.4.1",
"@types/marked": "^4.0.3",
Expand Down
4 changes: 2 additions & 2 deletions integration/helpers/node-template/app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hydrateRoot } from "react-dom/client";
import { RemixBrowser } from "@remix-run/react";
import { hydrate } from "react-dom";

hydrate(<RemixBrowser />, document);
hydrateRoot(document, <RemixBrowser />);
40 changes: 32 additions & 8 deletions integration/helpers/node-template/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
import { PassThrough } from "stream";
import { renderToPipeableStream } from "react-dom/server";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { renderToString } from "react-dom/server";

const ABORT_DELAY = 5000;

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
let markup = renderToString(
<RemixServer context={remixContext} url={request.url} />
);
return new Promise((resolve, reject) => {
let didError = false;

let { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onShellReady() {
let body = new PassThrough();

responseHeaders.set("Content-Type", "text/html");
responseHeaders.set("Content-Type", "text/html");

return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode,
headers: responseHeaders,
resolve(
new Response(body, {
status: didError ? 500 : responseStatusCode,
headers: responseHeaders,
})
);
pipe(body);
},
onShellError(err) {
reject(err);
},
onError(error) {
didError = true;
console.error(error);
},
}
);
setTimeout(abort, ABORT_DELAY);
});
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@
"@rollup/plugin-node-resolve": "^11.0.1",
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/react": "^13.3.0",
"@types/cheerio": "^0.22.22",
"@types/cross-spawn": "^6.0.2",
"@types/glob": "7.2.0",
"@types/jest": "^27.4.1",
"@types/jsonfile": "^6.1.0",
"@types/lodash": "^4.14.182",
"@types/node-fetch": "^2.5.7",
"@types/react": "^17.0.24",
"@types/react-dom": "^17.0.9",
"@types/react-test-renderer": "^17.0.1",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-test-renderer": "^18.0.0",
"@types/retry": "^0.12.0",
"@types/semver": "^7.3.4",
"@types/ssri": "^7.1.0",
Expand All @@ -104,8 +104,8 @@
"npm-run-all": "^4.1.5",
"prettier": "2.7.1",
"prompt-confirm": "^2.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remark": "14.0.2",
"remark-frontmatter": "4.0.1",
"remark-gfm": "3.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@remix-run/react": "1.3.4",
"@remix-run/serve": "1.3.4",
"marked": "^4.0.12",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix": "1.3.4",
"tiny-invariant": "^1.2.0"
},
Expand All @@ -35,12 +35,12 @@
"@remix-run/eslint-config": "1.3.4",
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/eslint": "^8.4.1",
"@types/marked": "^4.0.2",
"@types/react": "^17.0.40",
"@types/react-dom": "^17.0.13",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^1.2.0",
"c8": "^7.11.0",
"cross-env": "^7.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"@remix-run/node": "*",
"@remix-run/react": "*",
"@remix-run/serve": "*",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "*",
"@types/node": "^17.0.35",
"@types/react": "^17.0.45",
"@types/react-dom": "^17.0.17",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"typescript": "^4.7.4"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"devDependencies": {
"@types/eslint": "^8.4.1",
"eslint": "^8.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.7.4"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/remix-express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compilerOptions": {
"lib": ["ES2019", "DOM.Iterable"],
"target": "ES2019",
"skipLibCheck": true,

"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
Expand Down
10 changes: 2 additions & 8 deletions packages/remix-react/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// @ts-nocheck
import * as AbortController from "abort-controller";
import * as nodeFetch from "@remix-run/node/fetch";
import { installGlobals } from "@remix-run/node";

global.AbortController = AbortController.AbortController;
global.Headers = nodeFetch.Headers;
global.Response = nodeFetch.Response;
global.Request = nodeFetch.Request;
global.fetch = nodeFetch;
installGlobals();
4 changes: 2 additions & 2 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import type { Transition, Fetcher, Submission } from "./transition";
interface RemixEntryContextType {
manifest: AssetsManifest;
matches: BaseRouteMatch<ClientRoute>[];
routeData: { [routeId: string]: RouteData };
routeData: RouteData;
actionData?: RouteData;
pendingLocation?: Location;
appState: AppState;
Expand Down Expand Up @@ -719,7 +719,7 @@ export function Meta() {
}

if (name === "title") {
return <title key="title">{value}</title>;
return <title key="title">{String(value)}</title>;
}

// Open Graph tags use the `property` attribute, while other meta tags
Expand Down
6 changes: 3 additions & 3 deletions packages/remix-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/react": "^13.3.0",
"abort-controller": "^3.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"react": ">=16.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-server-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@remix-run/web-file": "^3.0.2",
"@types/jsesc": "^2.5.1",
"@types/set-cookie-parser": "^2.4.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"react": ">=16.8",
Expand Down
8 changes: 4 additions & 4 deletions scripts/playground/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"express": "^4.18.1",
"get-port": "^6.1.2",
"morgan": "^1.10.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tiny-invariant": "^1.2.0"
},
"devDependencies": {
"@faker-js/faker": "^6.3.1",
"@remix-run/dev": "^1.4.3",
"@types/bcryptjs": "^2.4.2",
"@types/node": "^17.0.31",
"@types/react": "^17.0.44",
"@types/react-dom": "^17.0.16",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"autoprefixer": "^10.4.7",
"cross-env": "^7.0.3",
"npm-run-all": "^4.1.5",
Expand Down
Loading