Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
Why is my React code editor component not highlighted by PrismJs?

I just discovered PrismJs and it looks perfect. But for some reason, it doesn't highlight my code in following component :

import { useState, useEffect } from "react";
import Prism from "prismjs";

export default function EditCode() {
  const [content, setContent] = useState("");

  useEffect(() => {
    Prism.highlightAll();
  }, []);

  useEffect(() => {
    Prism.highlightAll();
  }, [content]);
  return (
    <section className="codeGlobalContainer">
      <textarea
        className="codeInput"
        value={content}
        onChange={(e) => setContent(e.target.value)}
      />
      <pre className="codeOutput">
        <code className={`language-javascript`}>{content}</code>
      </pre>
    </section>
  );
}

Is there anything missing to make it work ?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It's not specified on there npm page, but you need to download a themed CSS on there official site : PrismsJS Then, you just move the CSS file to your directory and import it in your component as usual :

import "../../styles/prism.css";
about 4 years ago · Juan Pablo Isaza Relatório

0

as @FlowRan mentioned you need to import any theme you want to use but Note: you do not need to download the themes separately as they come with the package. Import your theme in your file by using the import statement from- 'prismjs/themes/prism-{theme-name}.css';

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda