Skip to content

How to access states of all sub-editors within a PlateController? #3039

Answered by 12joan
atharvashukla asked this question in Q&A
Discussion options

You must be logged in to vote

One limitation of Jotai is you can only access its stores using React hooks, one hook per store. If your number of editors is unchanging, you can get the array of stores from usePlateControllerSelectors and then pass each store to a usePlateStore to get its editor ref.

If you don't have a constant number of editors, then you'll have to remount the component that contains the hooks every time the number changes. A key={stores.length} prop should do that.

I think the simplest solution would just be to pass a callback ref toeditorRef on each Plate component to register each editor with a global store.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@atharvashukla
Comment options

Answer selected by atharvashukla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants