Skip to content

Add useSyncExtensions hook for syncing external state.#6

Merged
smoores-dev merged 1 commit intomainfrom
useSyncExtensions
Nov 7, 2025
Merged

Add useSyncExtensions hook for syncing external state.#6
smoores-dev merged 1 commit intomainfrom
useSyncExtensions

Conversation

@smoores-dev
Copy link
Member

Keep compartmentalized extensions in sync with external state.

If the state that determines the value of a compartment necessarily lives outside the CodeMirror EditorState (say, an app-wide theme picker), this hook can be used to keep it in sync with the EditorState.

To avoid state tearing, this hook calls the setEditorState argument in the render phase. This means that it must be used in the component that owns the EditorState. If your EditorState lives in a global state manager, you should not use this hook.

Keep compartmentalized extensions in sync with external state.

If the state that determines the value of a compartment necessarily lives
outside the CodeMirror EditorState (say, an app-wide theme picker), this hook
can be used to keep it in sync with the EditorState.

To avoid state tearing, this hook calls the `setEditorState` argument in the
render phase. This means that it _must_ be used in the component that owns the
EditorState. If your EditorState lives in a global state manager, you should not
use this hook.
@smoores-dev smoores-dev merged commit 931eec8 into main Nov 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant