Plugin state change detection from React


So I have a PM plugin, it uses async inside, and communicates with the PM editor with transactions as it should be. (So, the user types, it has an update hook in it, which waits for stuff, and then, fires a transaction, and that transaction modifies the inner plugin state.) The plugin renders decorators, and the decoration rendering also happens as expected. If I query the pluginKey.getState(editor.state) it works as expected, I could see the modified state.

I have a react component, which should rerender when the plugin inner state changes. (I basically position and rerender a popup.)

const pluginState = useMemo(() => {
    return pluginKey.getState(editor.state);
  }, [editor, editor?.state]);

This fires when the cursor moves, but not fires when the plugin state changes.

What is the optimal way to detect inner plugin state changes as a react dependency? (I use tiptap, editor.view.state is the same as editor.state as I know.