Skip to content

Commit 7f1b57c

Browse files
authored
feat: Update partial hydration directive (#36868)
* chore: Update client directive to "use client" * Bump react-server-dom-webpack * Adjust react-server-dom-webpack import paths * Revert everything except directive change
1 parent db92b17 commit 7f1b57c

File tree

18 files changed

+20
-20
lines changed

18 files changed

+20
-20
lines changed

packages/gatsby-cli/src/structured-errors/error-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,9 @@ const errors = {
887887
context?.path ? ` for path "${context.path}"` : ``
888888
}
889889
890-
This can happen if interactive elements like "useEffect", "useState", "createContext" or event handlers are used in a component without declaring the "client export" directive at the top of the file.
890+
This can happen if interactive elements like "useEffect", "useState", "createContext" or event handlers are used in a component without declaring the "use client" directive at the top of the file.
891891
892-
Consider adding "client export" to the top of your file if your component is interactive, otherwise refactor your component so it can be statically rendered with React Server Components (RSC).
892+
Consider adding "use client" to the top of your file if your component is interactive, otherwise refactor your component so it can be statically rendered with React Server Components (RSC).
893893
`),
894894
level: Level.ERROR,
895895
docsUrl: `https://gatsby.dev/partial-hydration-error`,

packages/gatsby-link/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"sideEffects": false,
1717
"scripts": {
1818
"build": "npm-run-all --npm-path npm -s build:cjs build:esm",
19-
"postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"client export\"",
19+
"postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"use client\"",
2020
"build:cjs": "microbundle -f cjs --jsx React.createElement --generateTypes false -i src/index-cjs.js -o dist/index.js",
2121
"build:esm": "microbundle -f modern --jsx React.createElement --generateTypes false -o dist/index.mjs",
2222
"watch": "npm-run-all --npm-path npm -p watch:cjs watch:esm",

packages/gatsby-plugin-image/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "3.0.0-next.3",
44
"scripts": {
55
"build": "npm-run-all --npm-path npm -s clean -p build:*",
6-
"postbuild": "prepend-directive --files=dist/gatsby-image.browser.js,dist/gatsby-image.browser.modern.js --directive=\"client export\"",
6+
"postbuild": "prepend-directive --files=dist/gatsby-image.browser.js,dist/gatsby-image.browser.modern.js --directive=\"use client\"",
77
"build:gatsby-node": "tsc --jsx react --downlevelIteration true --skipLibCheck true --esModuleInterop true --outDir dist/ src/gatsby-node.ts src/babel-plugin-parse-static-images.ts src/resolver-utils.ts src/types.d.ts -d --declarationDir dist/src",
88
"build:gatsby-ssr": "microbundle -i src/gatsby-ssr.tsx -f cjs -o ./[name].js --no-pkg-main --jsx React.createElement --jsxFragment React.Fragment --no-compress --external=common-tags,react --no-sourcemap",
99
"build:server": "microbundle -f cjs,es --jsx React.createElement --jsxFragment React.Fragment --define SERVER=true",

packages/gatsby-script/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"sideEffects": false,
1717
"scripts": {
1818
"build": "microbundle -f cjs,modern --jsx React.createElement && tsc --emitDeclarationOnly --declaration --declarationDir dist",
19-
"postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"client export\"",
19+
"postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"use client\"",
2020
"watch": "microbundle watch -f cjs,modern --jsx React.createElement --no-compress",
2121
"prepare": "cross-env NODE_ENV=production npm run clean && npm run build",
2222
"clean": "del-cli dist/*"

packages/gatsby/src/utils/webpack/loaders/__tests__/fixtures/cjs-exports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"client export"
1+
"use client"
22

33
exports.a = {
44
b: 1

packages/gatsby/src/utils/webpack/loaders/__tests__/fixtures/cjs-module-exports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"client export"
1+
"use client"
22

33
// TODO: Handle, otherwise remove and document if we decide not to support or it's not supported by React's implementation
44

packages/gatsby/src/utils/webpack/loaders/__tests__/fixtures/esm-aggregation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"client export"
1+
"use client"
22

33
// TODO: Handle, otherwise remove and document if we decide not to support or it's not supported by React's implementation
44

packages/gatsby/src/utils/webpack/loaders/__tests__/fixtures/esm-declaration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"client export"
1+
"use client"
22

33
export let a, b
44
export var c, d
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"client export"
1+
"use client"
22

33
export default class {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"client export"
1+
"use client"
22

33
export default class ClassName {}

0 commit comments

Comments
 (0)