Commit bdfa4e6
committed
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.
DiffTrain build for commit 2b3d582.1 parent 57f7532 commit bdfa4e6
File tree
7 files changed
+9
-9
lines changed- compiled-rn/facebook-fbsource/xplat/js
- RKJSModules/vendor
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
7 files changed
+9
-9
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23998 | 23998 | | |
23999 | 23999 | | |
24000 | 24000 | | |
24001 | | - | |
| 24001 | + | |
24002 | 24002 | | |
24003 | 24003 | | |
24004 | 24004 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8620 | 8620 | | |
8621 | 8621 | | |
8622 | 8622 | | |
8623 | | - | |
| 8623 | + | |
8624 | 8624 | | |
8625 | 8625 | | |
8626 | 8626 | | |
| |||
8651 | 8651 | | |
8652 | 8652 | | |
8653 | 8653 | | |
8654 | | - | |
| 8654 | + | |
8655 | 8655 | | |
8656 | 8656 | | |
8657 | 8657 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9046 | 9046 | | |
9047 | 9047 | | |
9048 | 9048 | | |
9049 | | - | |
| 9049 | + | |
9050 | 9050 | | |
9051 | 9051 | | |
9052 | 9052 | | |
| |||
9077 | 9077 | | |
9078 | 9078 | | |
9079 | 9079 | | |
9080 | | - | |
| 9080 | + | |
9081 | 9081 | | |
9082 | 9082 | | |
9083 | 9083 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | | - | |
| 619 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
| 622 | + | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments