Skip to content

Commit

Permalink
refactor(editor): migrate to latest version of `@codemirror-toolkit/r…
Browse files Browse the repository at this point in the history
…eact`
  • Loading branch information
exuanbo committed Dec 18, 2023
1 parent b741250 commit 9046356
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/features/editor/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const CodeMirror = ({ className }: Props): JSX.Element => {
const containerRef = useContainerRef()

useViewEffect((view) => {
const destructors = viewEffects.map((effect) => effect(view))
return () => destructors.forEach((dtor) => dtor?.())
}, [])
const cleanups = viewEffects.map((effect) => effect(view))
return () => cleanups.forEach((cleanup) => cleanup?.())
})

return (
<div
Expand Down
6 changes: 3 additions & 3 deletions src/features/editor/effects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Transaction } from '@codemirror/state'
import { addUpdateListener } from '@codemirror-toolkit/extensions'
import type { ViewEffectCallback } from '@codemirror-toolkit/react'
import type { ViewEffectSetup } from '@codemirror-toolkit/react'
import { mapRangeSetToArray, rangeSetsEqual } from '@codemirror-toolkit/utils'
import { debounceTime, filter, identity, map, of, switchMap } from 'rxjs'

Expand Down Expand Up @@ -30,7 +30,7 @@ import {
import { isTemplate, templateSelection } from './examples'
import { selectCurrentStatementLinePos } from './selectors'

const defineViewEffect = identity<ViewEffectCallback>
const defineViewEffect = identity<ViewEffectSetup>

const resetAssemblerStateOnInput = defineViewEffect((view) => {
const viewUpdate$ = onUpdate(view)
Expand Down Expand Up @@ -215,7 +215,7 @@ const toggleVimKeybindings = defineViewEffect((view) => {
)
})

export const viewEffects: readonly ViewEffectCallback[] = [
export const viewEffects: readonly ViewEffectSetup[] = [
resetAssemblerStateOnInput,
syncInputToState,
syncInputFromState,
Expand Down

0 comments on commit 9046356

Please sign in to comment.