dillon1000/react
Commit
Browse files useFormState: Hash the component key path for more compact output (#27397)
To support MPA-style form submissions, useFormState sends down a key that represents the identity of the hook on the page. It's based on the key path of the component within the React tree; for deeply nested hooks, this keypath can become very long. We can hash the key to make it shorter. Adds a method called createFastHash to the Stream Config interface. We're not using this for security or obfuscation, only to generate a more compact key without sacrificing too much collision resistance. - In Node.js builds, createFastHash uses the built-in crypto module. - In Bun builds, createFastHash uses Bun.hash. See: https://bun.sh/docs/api/hashing#bun-hash I have not yet implemented createFastHash in the Edge, Browser, or FB (Hermes) stream configs because those environments do not have a built-in hashing function that meets our requirements. (We can't use the web standard `crypto` API because those methods are async, and yielding to the main thread is too costly to be worth it for this particular use case.) We'll likely use a pure JS implementation in those environments; for now, they just return the original string without hashing it. I'll address this in separate PRs.
Changed paths14 files
First-parent comparison.eslintrc.js ModifiedM packages/react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig.js ModifiedM packages/react-server-dom-fb/src/ReactServerStreamConfigFB.js ModifiedM packages/react-server/src/ReactFizzHooks.js ModifiedM packages/react-server/src/ReactServerStreamConfigBrowser.js ModifiedM packages/react-server/src/ReactServerStreamConfigBun.js ModifiedM packages/react-server/src/ReactServerStreamConfigEdge.js ModifiedM packages/react-server/src/ReactServerStreamConfigNode.js ModifiedM packages/react-server/src/forks/ReactServerStreamConfig.custom.js ModifiedM scripts/flow/environment.js ModifiedM scripts/rollup/bundles.js ModifiedM scripts/rollup/validate/eslintrc.cjs.js ModifiedM scripts/rollup/validate/eslintrc.cjs2015.js ModifiedM scripts/rollup/validate/eslintrc.esm.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…