为什么CKEditor在NextJS中设置为true,为什么CKEditor卸载
那么他是我的代码来初始化编辑器。
const editorRef = useRef()
const [ editorLoaded, setEditorLoaded ] = useState( false )
const { CKEditor, ClassicEditor } = editorRef.current || {}
useEffect( () => {
editorRef.current = {
CKEditor: require( '@ckeditor/ckeditor5-react' ).CKEditor,
ClassicEditor: require( '@ckeditor/ckeditor5-build-classic' )
}
setEditorLoaded( true )
}, [] )
return (
<div className='w-full h-full' >
<h1>Ckeditor5 Nextjs</h1>
{
editorLoaded ?
<CKEditor className="mt-3 wrap-ckeditor" editor={ClassicEditor} onReady={editor => {
console.log(editor);
}} />
:
"loading..."
}
</div>
)
}
因此,如果ReactStrictMode
设置为true
编辑器将加载并在几百毫秒之后卸载,
so he is my code for initializing the editor
const editorRef = useRef()
const [ editorLoaded, setEditorLoaded ] = useState( false )
const { CKEditor, ClassicEditor } = editorRef.current || {}
useEffect( () => {
editorRef.current = {
CKEditor: require( '@ckeditor/ckeditor5-react' ).CKEditor,
ClassicEditor: require( '@ckeditor/ckeditor5-build-classic' )
}
setEditorLoaded( true )
}, [] )
return (
<div className='w-full h-full' >
<h1>Ckeditor5 Nextjs</h1>
{
editorLoaded ?
<CKEditor className="mt-3 wrap-ckeditor" editor={ClassicEditor} onReady={editor => {
console.log(editor);
}} />
:
"loading..."
}
</div>
)
}
if reactStrictMode
is set to true
the editor will load and then unload after a few hundred milliseconds why is this the case ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论