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

149
Vistas
Can not set Cytoscapejs container element in next js

Im working on a Next.js project that requires the use of cytoscapejs. So far I have tried to type document.getElementById('cy') and $('#cy') but none of those work.

import Head from "next/head"
import cytoscape from 'cytoscape';

var cy = cytoscape({

  //container: !!??!!

  elements: [],

  style: [],

  layout: {}
});



export default function Grafo1() {

    return (
        <div>
            <Head>
              <title>Graph 1.</title>
            </Head>

            
            <div id="cy">
              //graph here
            </div>
            
        </div>
    )
}

I have tried a react library called react-cytoscape but thows an error "window is not defined" when I refresh the page becouse nextjs works with ssr and the graph component falls apart when refreshed. Also tried the dynamic module that deactivates ssr but still doesn`t work.

I`d style this somewhere else. Any ideas?

about 4 years ago · Santiago Trujillo
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