dillon1000/react
Commit
Browse files useId: Use 'H' to separate main id from hook index (#23363)
No id should be a subset of any other id. Currently, this is not true when there are multiple hooks in the same component. We append the hook index to the end of the id, except for the first one. So you get this pattern. Before this change: - 1st hook's id: :R0: - 2nd hook's id: :R0:1: The first hook's id is a subset of all the other ids in the same component. The fix for this is to use a different character to separate the main id from the hook index. I've chosen a captial 'H' for this because capital letters are not part of the base 32 character set when encoding with `toString(32)`. After this change: - 1st hook's id: :R0: - 2nd hook's id: :R0H1:
Changed paths4 files
First-parent comparisonpackages/react-dom/src/__tests__/ReactDOMUseId-test.js ModifiedM packages/react-dom/src/server/ReactDOMServerFormatConfig.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.new.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.old.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…