Ckeditor is null(gone) when i push f5 refresh in React

Viewed 256

I'm use Ckeditor in my react project.

But when i refresh the page then Ckeditor is gone.

Only first when i open the page then show.

What is the problem?

1 Answers

I too had the same issue. I think it has something to do with the ckeditor's editor value.

Try to use this code while in development and use the default code which is given in example in production build.

Not sure if this is a good practise but it serves the purpose.

    const [state, setState] = useState({
        data: (props.children.toString() || ""),
        editor: null
    })
    useEffect(() => {
        console.log(state.data);
        const editor = (
            <CKEditor
                id={"ck-editor-text"}
                editor={ClassicEditor}
                data={state.data}
                onReady={editor => {console.log('Editor is ready to use!', editor)}}
            />
        )
        setState({...state, editor: editor});
    }, [])
    return (
        <div className={style.wrapper}>
            <div className={"w-64"} id={"ck-editor-text"}>
                {state.editor}
            </div>
        </div>
    )
Related