Firstly I create react project then I installed jodit-react. When I run a program its showing error "self is not defined". then I add below code to my page.js.
const JoditEditor = dynamic(() => import("../../node_modules/jodit-react"), { ssr: false, }); And Now still getting this error
This is all dependencies:- "dependencies": { "jodit-react": "^1.3.39", "next": "14.0.3", "react": "^18", "react-dom": "^18" },
I added code but still not able to fetch rich-text-editor
This is my page.js code
"use client";
import dynamic from "next/dynamic";
import { useRef, useState useMemo } from "react";
export default function Home() {
const editor = useRef(null);
const [content, setContent] = useState('');
Define a placeholder or use an empty string if placeholder is not provided
const placeholder = ''; // Replace with your desired placeholder value
const config = useMemo({
readonly: false,
placeholder: placeholder || 'Start typing...',
[placeholder] );
const JoditEditor = dynamic(() => import("../../node_modules/jodit-react"), {
ssr: false,
});
return (
<JoditEditor
ref={editor}
value={content}
config={config}
tabIndex={1} // tabIndex of textarea
onBlur={newContent => setContent(newContent)}
onChange={newContent => {setContent(newContent)}} />
)}