mkhstar / suneditor-react

A React Component for SunEditor (WYSIWYG editor)
http://suneditor.com/
427 stars 105 forks source link

Not working with Nextjs 13 using next/dynamic #327

Open perklet opened 1 year ago

perklet commented 1 year ago

I tried to use next/dynamic from the README file, but nextjs 13 still complains about document is undefined error. Then I tried use client, it works. However, is it the right way to do this? If so, should the README file be updated?

My fix is:

// page.tsx
import SunEditor from "../components/Editor"
// Editor.tsx
'use client'                                                                              
import SunEditor from 'suneditor-react'      
import 'suneditor/dist/css/suneditor.min.css'                                             
export default function Editor() {
    return <SunEditor />                       
}