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

254
Vistas
Module Build Failed: Duplicate Declaration "Editor"

I am trying to implement "RichEditor" example provided by Facebook in my project Here is the code:

import React from 'react;
import { Component } from 'react';
import { Editor, EditorState, RichUtils } from 'draft-js';
import { Map } from 'immutable';

'use strict';

const { Editor, EditorState, RichUtils } = Draft;

//rest of the code...

Whenever I tried to build using webpack-dev-server, I am getting the following error. I checked StackOverflow to see if some other user has encountered an exact error. But, couldn't find one.

Module Build Failed: Duplicate Declaration "Editor"

'use strict';
> const { Editor, EditorState, RichUtils } = Draft;

export class ...{}

Where am I going wrong?

Note: I am new to ReactJS.

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

0

You're importing Editor up top, and then you are also defining it again when you are destructuring Draft.

You either need to alias Editor in the import of draft-js like this:

import { Editor as DEditor, EditorState, RichUtils } from 'draft-js';

From here you would use Deditor instead of Editor. Then you would be free to name the const Editor below...

Or, just don't destructure the Draft object below.

Instead of const { Editor, EditorState, RichUtils } = Draft;, access the property of Draft with dot syntax. i.e. Draft.Editor, Draft.EditorState, etc...

over 4 years ago · Santiago Trujillo Denunciar

0

Also this duplicate declaration error happens if you are importing a predefined default import with the same name as a component somewhere else in your imports.

Example:

import bla from 'react-bla';
://more imports
://more imports
import bla from '../Components/bla/bla';
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