@blocknote/react
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
16 lines (12 loc) • 342 B
text/typescript
import { useEffect, useState } from "react";
export function useUIPluginState<State>(
onUpdate: (callback: (state: State) => void) => void,
): State | undefined {
const [state, setState] = useState<State>();
useEffect(() => {
return onUpdate((state) => {
setState({ ...state });
});
}, [onUpdate]);
return state;
}