-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element loses focus on first state change in React 18 #26
Comments
i'm seeing this error on react 18.2.0. first onChange loses focus, but the following ones keep focus. Example code: // EditableBlock.tsx
export const EditableBlock = ({
content,
onChange,
}: {
content: string;
onChange: (content: string) => void;
}) => {
const editorRef = useRef(null);
useEditable(editorRef, onChange);
return <div ref={editorRef}>{content}</div>;
}; // index.tsx
export default function Home() {
const [content, setContent] = React.useState('Hello world!');
const onChange = useCallback((content: string) => {
setContent(content);
console.log({ content });
}, []);
return <EditableBlock content={content} onChange={onChange} />;
} |
Is this library alive? Looking to use it in a project because it's approach looks better than react-contenteditable which doesnt really work properly with hooks |
I have the same issue, did anyone ever find a workaround? |
Should be fixed in #29 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you first change the content of the element you are interrupted, as if the element loses focus. I have tested this in multiple browsers and in multiple react versions. This problem only ocurs in React 18
Codesandbox
The text was updated successfully, but these errors were encountered: