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

137
Vistas
JavaScript $ReadOnlyArray<CompositeDecorator>

I'm trying to get some code working which will highlight links automatically in an rich text editor. This is not my own written code this is from draft js and is provided by many different web pages because this is the absolutlly basic how it should work out. My major problem is that when I deifinine the linkDecorator of the type CompositeDecorator the compiler tells me that the linkDecorator is $ReadOnlyArray which can't handle the provided input. I have absolutly no idea what I'm doing wrong because for people on about 10 different websites exactly this code works out well. Even in an online compiler were you can compile the code yourself it works. Also practically the programm won't throw errors but it simply won't do anything anymore after this line.

Thanks in advance for any help!!!

function findLinkEntities(contentBlock, callback, contentState){
    contentBlock.findEntityRanges((character) => {
        const entityKey = character.getEntity();
        return(
            entityKey !== null &&
                contentState.getEntity(entityKey).getElementById() === 'LINK'
        )
    }, callback);
}

const Link = (props) => {
    const { url,linkText} = props.contentState
        .getEntity(props.entityKey)
        .getData()
    return (
        <a style={{color: '#006cb7', textDecoration: 'underline'}}
            href={url}>
            {linkText || props.children}
        </a>
    )
}

const linkDecorator = new CompositeDecorator([
    {
        strategy: findLinkEntities,
        component: Link,
   }
])
about 4 years ago · Juan Pablo Isaza
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