This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
Prefer rolling index over random key generation. Prefix editor key with #582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Ref: #385
The current key generation method prohibits server-side rendering to have the same checksum when the editor is re-rendered on client side. The solution here is to keep editorKey in editorState so that developers have some control to retain the same editor key by sending the serialized editorState to client side.
There is also a performance concern on the current method to generate random keys. The method allows up to 2^24 keys in the seenKeys map. During generation, the method retries if a key previously used is generated again. This causes the process to retry more often as more keys get generated (evenly freezing) and would be a huge concern on server side rendering. The proposed method is to use a non-random but incrementing variable.