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

Why is initialValue required by slate-react's Slate component? #5605

Open
jacobcarpenter opened this issue Feb 9, 2024 · 0 comments
Open

Comments

@jacobcarpenter
Copy link
Contributor

jacobcarpenter commented Feb 9, 2024

The Slate component currently requires both an editor and an initialValue, the latter of which is then pushed into the editor instance.

However, it's easy for me to pre-construct an editor instance that has the children content already set, and I don't actually want to keep a reference to the actual initialValue content around for the whole lifetime of my Slate component.

I could also try to Render Slate with an empty editor and a lightweight dummy initialContent, and then immediately replace the content with my actual content. But this seems undesirable because of unnecessary renders, and potentially complicated timing/eventing logic to ensure the update runs after Slate runs its content replacement.

It seems like an improvement to make initialValue an optional prop, and validate that either initialValue is supplied (with all the same validation in place) or editor.children is a valid node list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant