Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
How to prefill CkEditor with data using React.js?

I'm creating a blog and I want to give the user the ability to update their post but I'm not sure how to pass the content data from the original post into my rich text editor.

import { CKEditor } from '@ckeditor/ckeditor5-react'
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'

function UpdatePost() {
  const [content, setContent] = useState('')
  const { post_id } = useParams();

 useEffect(() => {
    const fetchPost = async () => {
      const formData = await getPost(post_id);
      setContent(formData.content);
    };
    fetchPost();
  }, [post_id]);

 const handleSubmit = async (event) => {
    event.preventDefault();
    const updated = await updatePost({
      post_id,
      content: content,
    })
  };

 return (
    <div>
        <form
          onSubmit={handleSubmit}
        >
          <h1 class="create-post-header-text">Update Post</h1>
            <CKEditor
              config={{ placeholder: "Content..." }}
              class="ck-editor"
              editor={ClassicEditor}
              onChange={(event, editor) => {
                const data = editor.getData()
                setContent(data)
              }}
            />
          </label>
        </form>
    </div >
  );
} 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It may help, try this ...

 <CKEditor
              config={{ placeholder: "Content..." }}
              class="ck-editor"`enter code here`
              editor={ClassicEditor}
           data={<div dangerouslySetInnerHTML={{ __html: content }} />}
              onChange={(event, editor) => {
                const data = editor.getData()
                setContent(data)
              }}
            /

> 




about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda