Api for setting value from an external change
See original GitHub issueDo you want to request a feature or report a bug?
Feature request
What’s the current behavior?
There doesn’t appear to be a way to set the editor value externally e.g. from a prop change or other event that would warrant updating the value from outside the editor.
–>
Slate: 0.XX.X Browser: Chrome / Safari / Firefox / Edge OS: Mac / Windows / Linux / iOS / Android
What’s the expected behavior?
We should have a way to set the value externally.
One proposal that has been made is to be able to configure the editor as a controlled component, but there are likely tradeoffs with this. This issue is not intended to champion that particular proposal but rather to discuss what the “right” api might be. e.g. there could be options to call a method on the editor
or something more imperative.
NOTE: The idea has been discussed in #3200 of possibly using changes to defaultValue
as a way to set the value externally, but the current behavior seems consistent with other uncontrolled components in React.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Here’s what the
<Slate>
component would look like as a controlled component, for those who are interested: https://github.com/ianstormtaylor/slate/pull/3216Yes. I asked Ian on Slack why he chose to go with an uncontrolled component. He said: