You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ref function passed into RichTextEditor gets executed on every render. This makes it not possible to use ref callbacks for focusing the editor and forces us to use useEffect.
Describe the bug
The ref function passed into
RichTextEditor
gets executed on every render. This makes it not possible to use ref callbacks for focusing the editor and forces us to useuseEffect
.This is the line that is responsible for it: https://github.com/sjdemartini/mui-tiptap/blob/main/src/RichTextEditor.tsx#L104
There is no dependency array for
useImperativeHandle
.To Reproduce
Add this function below outside of the react component (so its stable) and add it as ref
Console is spammed with Focus. This f.e. makes it impossible to add a link since the focus will be stolen all the time
Expected behavior
ref callback is only executed once (maybe a few times, but only at the start or when the editor changes)
Fix
The text was updated successfully, but these errors were encountered: