Skip to content
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

Input form lose focus every time when typing a character #436

Closed
KirschX opened this issue Sep 22, 2022 · 2 comments
Closed

Input form lose focus every time when typing a character #436

KirschX opened this issue Sep 22, 2022 · 2 comments

Comments

@KirschX
Copy link

KirschX commented Sep 22, 2022

///component/MdEditor

const MdEditor = () => {
  const MDEditor = dynamic(() => import("@uiw/react-md-editor"), {
    ssr: false,
  });

  const [md, setMd] = useState<string | undefined>("# Hello World");

  let mdRef = useRef("");

  return <MDEditor value={md} onChange={setMd} />;
};

export default MdEditor;`

//main

<>
(some react-hook-form library component)
<>
 <div>
        <MdEditor />
</div>

Problem)
Every time I type 1 character, input field lose focus.
I also put it on parent(main) component but problem happend same again.
I don't think it's related with other libraries.
I think it is realated with rerendering or something, but can't find out how to handle this problem.

What is them problem and what can I do in this situation??

@KirschX KirschX changed the title input form lose focus every time when typing a character Input form lose focus every time when typing a character Sep 22, 2022
@jaywcjlove
Copy link
Member

@KirschX https://codesandbox.io/s/markdown-editor-for-react-izdd6?from-embed

I can't reproduce your problem, can you give me an example that reproduces this error.

@KirschX
Copy link
Author

KirschX commented Sep 23, 2022

@jaywcjlove Oh, sorry. I just solved the problem, I was stupid. I should have imported the the module outside of the function component.

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

No branches or pull requests

2 participants