slate icon indicating copy to clipboard operation
slate copied to clipboard

use with mobx-react-lite error

Open kringt06 opened this issue 1 year ago • 2 comments

Description

import { observer } from 'mobx-react-lite'

const App = observer(() => {
  return (
    <Slate.... />
  )
})

The initial rendering is correct, but an error occurs when inputting

Error: Cannot resolve a DOM point from Slate point: {"path":[0,0],"offset":1}

Recording image

kringt06 avatar Sep 14 '23 03:09 kringt06

If any parent component has an observer, there will be problems. If you remove the observer, there will be no problem.

kringt06 avatar Sep 14 '23 03:09 kringt06

After wrapping the editing component with a separate layer of memo, does it look normal again? I suspect that the refresh of the parent component will cause the slate exception.

import { observer } from 'mobx-react-lite'
import { memo } from 'react'

const App = observer(() => {
  return (
      <Main />
  )
})

const Main = memo(function T () {
  return <Slate.... />
})

kringt06 avatar Sep 14 '23 03:09 kringt06