Access React state from Slate plugin #4308
Unanswered
churichard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to access React state from inside of a Slate plugin? I've explored a few possibilities, outlined below. I'd like to know what way would be the best.
Store state outside of React
I know it's possible if you store state outside of React, e.g. with Zustand or Redux. However, I would prefer to keep my state inside of React if possible.
Pass state to the plugin function
It doesn't seem possible to just pass in the new state into the plugin, since the plugin is initialized with the editor, and the editor instance is not supposed to change.
Set state on the editor object
I guess you might also be able to set the state on the editor object itself and access it inside of the plugin? But that seems pretty hacky.
Is there something I'm missing?
Beta Was this translation helpful? Give feedback.
All reactions