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

useId: Use 'H' to separate main id from hook index #23363

Merged
merged 1 commit into from
Feb 25, 2022

Commits on Feb 25, 2022

  1. useId: Use 'H' to separate main id from hook index

    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:
    acdlite committed Feb 25, 2022
    Configuration menu
    Copy the full SHA
    6cd8428 View commit details
    Browse the repository at this point in the history