Skip to content

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

Open
@jacobcarpenter

Description

@jacobcarpenter

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions