-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Automatic ID generation does not work well with server rendering #1761
Comments
See also #1283 |
This issue has been inactive for 180 days and labeled with |
This is still an issue. |
I've been low-key working towards a solution for this. Here's a state of the world update History:
Mitigation so far:
The final fix for client/server mismatches will be contained within useUniqueId(). Next steps:
Consider moving Update our ID handling by either:
|
|
This issue has been inactive for 180 days and labeled with |
Still a problem |
c'mon now probot |
React 18 introduces |
This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. |
Issue summary
In the latest edition of "mistakes Chris made several years ago", it's been bugging me that the approach to doing automatic ID generation in Polaris doesn't work properly for server rendering. I think all cases that need an ID generate one using
createUniqueIDFactory
. This creates auto-incrementing IDs (they aren't guaranteed globally unique, but they're fine for our purposes). However, they rely on module-global variables, which means that each request a node server gets will increment those IDs, even though the client will always start them back at 0. This creates a mismatch between client and server markup (not a huge deal, but an annoying warning in dev at the very least).My proposal for addressing this would be to allow passing some sort of
idFactory
in to Polaris via context. ThisidFactory
could default to being module global (e.g.,const IdContext = createContext(idFactory())
), which preserves the 0-config behaviour. However, for our apps, we could provide a freshidFactory
for each server render, allowing it to remain consistent with the eventual client markup.Two things that would be nice to see out of it:
The text was updated successfully, but these errors were encountered: