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

  1. "use client";

  2. import dynamic from "next/dynamic";

  3. import { useRef, useState useMemo } from "react";

  4. export default function Home() {

  5. const editor = useRef(null);

  6. const [content, setContent] = useState('');

  7. Define a placeholder or use an empty string if placeholder is not provided

  8. const placeholder = ''; // Replace with your desired placeholder value

  9. const config = useMemo({

  10. readonly: false,

  11. placeholder: placeholder || 'Start typing...',

  12. [placeholder] );

  13. const JoditEditor = dynamic(() => import("../../node_modules/jodit-react"), {

  14. ssr: false,

  15. });

  16. return (

  17. <JoditEditor

  18. ref={editor}

  19. value={content}

  20. config={config}

  21. tabIndex={1} // tabIndex of textarea

  22. onBlur={newContent => setContent(newContent)}

  23. onChange={newContent => {setContent(newContent)}} />

  24. )}

0

There are 0 answers