question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'destruct' of null

See original GitHub issue

When I go to save I get this error:

app.js:formatted:6369 Uncaught TypeError: Cannot read property 'destruct' of null
    at app.js:formatted:6369
    at HTMLUnknownElement.callCallback (vendor.js:23251)
    at Object.invokeGuardedCallbackDev (vendor.js:23300)
    at invokeGuardedCallback (vendor.js:23362)
    at flushPassiveEffectsImpl (vendor.js:42844)
    at unstable_runWithPriority (app.js:formatted:36153)
    at runWithPriority$1 (vendor.js:30582)
    at flushPassiveEffects (vendor.js:42748)
    at vendor.js:42780
    at workLoop (app.js:formatted:36097)

The formatted vendor code is:

Object(e.useEffect)((function() {
    var t = u.current;
    return u.current = a.Jodit.make(t, i),
    u.current.workplace.tabIndex = c || -1,
    u.current.events.on("blur", (function(t) {
        return l && l(t)
    }
    )),
    u.current.events.on("change", (function(t) {
        return s && s(t)
    }
    )),
    d && (t.id = d),
    n && (t.name = n),
    "function" == typeof p && p(u.current),
    function() {
        u.current.destruct(),
        u.current = t
    }
}

Which seems to be this source code: In particular line 47

https://github.com/jodit/jodit-react/blob/9497b6769402160e9302797558509702c6579673/src/JoditEditor.js#L30-L50

I’m wondering if the SPA navigates away and the referenced element no longer exists? If I breakpoint the code it doesn’t break, and doesn’t navigate away, but if I remove the breakpoint it goes back to breaking.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:13

github_iconTop GitHub Comments

2reactions
ssuettenbachcommented, Mar 10, 2021

We have the same message. We are using React and since updating our dependencies from React-DOM v16 to v17 the error appears everytime the JoditEditor is removed from the viewport, for example like page-navigation or hiding the editor.

No useEffect or hooks!

export const TextEditor = (props: TextEditorProps): JSX.Element => {
  const [content, setContent] = useState(props.content || "");
  const [showEditor, setShowEditor] = useState(false);

  const onBlur = (newContent) => {
    setContent(newContent);
    setShowEditor(false);
  }

  if (showEditor) {
   // show preview
   return (
      <div
        className={`texteditor-readonly ${content ? "" : "text-light"}`}
        style={{ height: props.fullSize ? "100%" : "auto" }}
        onClick={()=> setShowEditor(true)}
      >
          {content}
      </div>
    );
  } else {
    // show editor
    return (
      <JoditTextEditor content={content} onBlur={(evt: any) => onBlur(evt.target.innerHTML)} />
    );
  }
2reactions
luckylkscommented, Jan 27, 2021

Any solution to this problem? I used the code presented in the README.md at https://github.com/jodit/jodit-react and I am launching the editor in a modal. The error occurs on both Save and Cancel events of the modal that automatically close the modal as well as the editor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot read property of null doing destructing - Stack Overflow
In Javascript, a variable can be assigned a default, in the case that the value unpacked from the object / array is undefined....
Read more >
How to deal or remove "Cannot read property 'destroy' of null"
"Cannot read property 'destroy' of null" - This error has occurred because the underlying js implementation gets failed to initialize the global ......
Read more >
Javascript – cannot read property of null doing destructing
Destructing is cool but I start to encounter serious issues when doing destructing of nested objects. I have this code:
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
Same as accessing properties, destructuring null or undefined throws a TypeError . const { a } = undefined; // TypeError: Cannot destructure ...
Read more >
[Solved]-cannot read property of null doing destructing-Reactjs
In Javascript, a variable can be assigned a default, in the case that the value unpacked from the object / array is undefined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found