GithubHelp home page GithubHelp logo

Comments (16)

jaywcjlove avatar jaywcjlove commented on May 27, 2024 2

@ifbarrera

<Form.Item
  name="editor"
+   initialValue="test"
>
  <MDEditor value={"sample value"} autoFocus={0} />
</Form.Item>

from react-md-editor.

an-lee avatar an-lee commented on May 27, 2024 1

Got the same issue when upgrade to 2.1.8 from 2.1.2. Also using with antd form component.

Solved by providing an initialValue.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

@Formalibus Upgrade v2.1.8

from react-md-editor.

Formalibus avatar Formalibus commented on May 27, 2024

@Formalibus Upgrade v2.1.8

I was actually at v2.1.8 then this error occured
I am on v2.1.2 it's working

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

Can you provide an example?
@Formalibus

from react-md-editor.

Formalibus avatar Formalibus commented on May 27, 2024

here my imports
изображение

here I call it
<div className="row markdownEditor">
<div className="col-sm">
<MDEditor preview="edit" height="730" onChange={setContent} />
</div>
<div className="col-sm">
<MDEditor.Markdown source={content} />
</div>
</div>
now it working on v2.1.2
изображение

from react-md-editor.

Formalibus avatar Formalibus commented on May 27, 2024

now I updated md editor
изображение
and got this
изображение
TypeError: text is undefined
matchGrammar
C:/Users/Udodelighed/react_lessons/destination_pamir/node_modules/prismjs/prism.js:887

884 |
885 | var str = currentNode.value;
886 |

887 | if (tokenList.length > text.length) {
| ^ 888 | // Something went terribly wrong, ABORT, ABORT!
889 | return;
890 | }

tokenize
C:/Users/Udodelighed/react_lessons/destination_pamir/node_modules/prismjs/prism.js:655

652 | var tokenList = new LinkedList();
653 | addAfter(tokenList, tokenList.head, text);
654 |

655 | matchGrammar(text, tokenList, grammar, tokenList.head, 0);
| ^ 656 |
657 | return toArray(tokenList);
658 | },

highlight
C:/Users/Udodelighed/react_lessons/destination_pamir/node_modules/prismjs/prism.js:613

610 | language: language
611 | };
612 | _.hooks.run('before-tokenize', env);

613 | env.tokens = _.tokenize(env.code, env.grammar);
| ^ 614 | .hooks.run('after-tokenize', env);
615 | return Token.stringify(
.util.encode(env.tokens), env.language);
616 | },

highlight
C:/src/components/TextArea/index.tsx:36

33 | const [value, setValue] = useState(props.value);
34 | const highlight = () => {
35 | const pre = preElm.current;

36 | const html = Prism.highlight(value as string, Prism.languages.markdown, 'markdown');
| ^ 37 | pre!.innerHTML = ${html}<br />;
38 | };
39 | useEffect(() => {

./node_modules/@uiw/react-md-editor/lib/esm/components/TextArea/index.js/webpack_exports.default</<
C:/src/components/TextArea/index.tsx:51

48 | }
49 | }, [props.value]);
50 |

51 | useEffect(() => highlight(), [value]);
| ^ 52 | useEffect(() => {
53 | if (props.autoFocus && textElm.current) {
54 | textElm.current.focus();

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

@Formalibus I cannot help you resolve the error.

Project example ? Put it in the repositories?

from react-md-editor.

Formalibus avatar Formalibus commented on May 27, 2024

no need, thanks )))
just wanted to notify about issue
if you want I can close an issue

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

:(

from react-md-editor.

ifbarrera avatar ifbarrera commented on May 27, 2024

Hi, I'm also getting this error on 2.1.8, react v. 16.14.0.

Usage:

import MDEditor from '@uiw/react-md-editor';

<MDEditor value={"sample value"} autoFocus={0} />

Error:
image

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

@ifbarrera https://codesandbox.io/s/markdown-editor-for-react-forked-2fzdr

from react-md-editor.

ifbarrera avatar ifbarrera commented on May 27, 2024

@jaywcjlove updated your code sandbox: https://codesandbox.io/s/markdown-editor-for-react-forked-19hfr?file=/index.js

Seems to be related to having MDEditor as part of a form, and setting its value with React.useEffect.

In my app, I use React.useEffect to pre-populate a previously saved value.

from react-md-editor.

ifbarrera avatar ifbarrera commented on May 27, 2024

You can't dynamically change initialValue or defaultValue on forms based on state. https://ant.design/docs/react/faq#It-doesn't-work-when-I-change-defaultValue-dynamically

This is why I use the React.useEffect hook.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on May 27, 2024

@ifbarrera https://ant.design/components/form/#components-form-demo-customized-form-controls

from react-md-editor.

an-lee avatar an-lee commented on May 27, 2024

btw, for 2.1.8 version, the props autoFocus seems not working. It always auto focus even autoFocus={false} is set. @jaywcjlove

from react-md-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.