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

322
Vistas
Draft.JS: the proper way to detect content change

There is onChange event, but it fires also when carret moves or navigation (arrows etc) button being pushed.

I want to detect if content was changed. Basically i need to detect this only once when the very first change occur. The dumb way "compare content" may work here, but this is an anti-pattern because this task is too resources-expensive.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since Draft uses an immutable data structure, it doesn't have to be that resource heavy – comparing references should be enough:

onChange(newEditorState) {
  const currentContent = this.state.editorState.getCurrentContent()
  const newContent = newEditorState.getCurrentContent()

  if (currentContent !== newContent) {
    // Content has changed
  }
}
over 4 years ago · Santiago Trujillo 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