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.

Example from doc not working (TypeError value must be string)

See original GitHub issue

I’ve tried jodit-react with the most basic example I could find but it breaks after typing a few words in the editor.

Steps to reproduce:

  1. Go to: https://codesandbox.io/s/sleepy-colden-1twnp
  2. Type a few things in the editor
  3. Wait for a bit
  4. Watch it break with TypeError value must be string

jodit-react-issue

Code to reproduce locally:

index.js

import React from "react";
import ReactDOM from "react-dom";

import App from "./App";

const rootElement = document.getElementById("root");
ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  rootElement
);

App.js

import React from "react";
import "./styles.css";
import Editor from "./Editor";

export default function App() {
  return <Editor />;
}

Editor.js

import React, { useState, useRef } from "react";
import JoditEditor from "jodit-react";

const Example = ({}) => {
  const editor = useRef(null);
  const [content, setContent] = useState("");

  const config = {
    readonly: false // all options from https://xdsoft.net/jodit/doc/
  };

  return (
    <JoditEditor
      ref={editor}
      value={content}
      config={config}
      tabIndex={1} // tabIndex of textarea
      onBlur={(newContent) => setContent(newContent)} // preferred to use only this option to update the content for performance reasons
      onChange={(newContent) => {}}
    />
  );
};

export default Example;

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

6reactions
chassteelcommented, Sep 15, 2020

This can be fixed by changing the onBlur to:

onBlur={(newContent) => setContent(newContent.target.innerHTML)}

This may be a bug though (and so may be fixed in future) since the onChange event passes the target.innerHTML directly.

0reactions
ctsstccommented, Nov 5, 2020

Same as #91 and a good PR on #103 that includes the standard event too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm getting a TypeError. How do I fix it? - Stack Overflow
TypeError : int() argument must be a string, a bytes-like object or a number, not 'list' TypeError: a bytes-like object is required, ...
Read more >
TypeError: can't assign to property "x" on "y": not an object
In strict mode, a TypeError is raised when attempting to create a property on primitive value such as a symbol, a string, a...
Read more >
TypeError String Indices Must be Integers Python Error [Solved]
If you try to access values from a dictionary or iterable object using the string value instead of the integer value then you...
Read more >
How to Fix: Typeerror: expected string or bytes-like object
This error typically occurs when you attempt to use the re.sub() function to replace certain patterns in an object but the object you're...
Read more >
Node.js v19.3.0 Documentation
Please read the example in assert.throws() carefully if using a string as the second argument gets considered. assert.snapshot(value, name) ...
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