Example from doc not working (TypeError value must be string)
See original GitHub issueI’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:
- Go to: https://codesandbox.io/s/sleepy-colden-1twnp
- Type a few things in the editor
- Wait for a bit
- Watch it break with TypeError value must be string
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:
- Created 3 years ago
- Reactions:6
- Comments:6
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Same as #91 and a good PR on #103 that includes the standard event too.