Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/core/src/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ export const Editor = ({ children, ...options }: EditorProps) => {
}, [context, options.enabled]);

React.useEffect(() => {
// Only set up the serialize-and-compare subscription when the consumer
// actually provided an onNodesChange callback. The subscription serializes
// the entire node tree (JSON.stringify) on every store change just to
// detect whether the callback should fire, which is pure overhead for
// consumers that never passed onNodesChange (e.g. read-only viewers
// receiving frequent runtime prop updates).
if (!context || !optionsRef.current.onNodesChange) {
return;
}

context.subscribe(
(_) => ({
json: context.query.serialize(),
Expand Down