feat: move ID utilities to react-uid#142
Conversation
|
Also, this PR is exploratory. There's no need to merge if we don't feel it's the right path. |
jzempel
left a comment
There was a problem hiding this comment.
Works for me. Will be interested in feedback from @ryanseddon.
There's a pull request to add a |
12a5000 to
1369d04
Compare
|
I've updated this to now include the package name and |
|
LGTM will be interesting if this can be superseded by a react built in hook proposed in facebook/react#17322 Is the reason to pull it out of container-utilities to avoid dependency mismatches? |
This would be the best path since
Yes, but the main fix for that is including the package name and version in the seed generators. Moving to |
Description
Our current ID management solution uses a shared variable that is incremented on each call. This works well for basic use-cases, but is dependent on the render order to be consistent. This can cause issues with SSR and code-splitting scenarios.
We have also seen issues with consumers upgrading dependencies and having duplicate IDs from conflicting
container-utilitiesversions.Detail
A popular solution seems to be the uuid library, but this isn't viable for SSR and reproducible snapshot testing.
Looking through a react issue I found a reference to https://www.npmjs.com/package/react-uid which seems to match our use-case well.
Some highlights:
@ryanseddon this seems like it could be a good utility for usage in the product specific codebases.
Checklist
yarn start)