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

172
Visualizações
Having trouble getting coverflow.js JQuery module to work in Next.JS

I am trying to use the JQuery library coverflow.js to work in Next.JS. Using the solution to 61029733 as a starting point (fresh clone of the repo), I added coverflow.min.js to the public folder and added a single line to JqueryDiamonds.js as shown below:

useEffect(() => {
    window.jQuery = require('../public/jquery-latest.min');
    window.Diamonds = require('../public/jquery.diamonds.js');
    window.Coverflow = require("../public/coverflow.min.js");

    window.jQuery("#demo").diamonds({
        size : 100, // Size of diamonds in pixels. Both width and height.
        gap : 5, // Pixels between each square.
        hideIncompleteRow : false, // Hide last row if there are not enough items to fill it completely.
        autoRedraw : true, // Auto redraw diamonds when it detects resizing.
        itemSelector : `.${styles.item}` // the css selector to use to select diamonds-items.
    });
}, []);

I get the following runtime error:

TypeError: Cannot read properties of undefined (reading 'createElement')

The same happens if I use the un-minified version of Coverflow coverflow.js:

Uncaught TypeError: Cannot read properties of undefined (reading 'createElement')
at coverflow.js:2469:1

The code at this line is:

var el = document.createElement( "div" ),

I am very confused why createElement, a vanilla JavaScript function, is giving an error. Maybe it has something to do with document not being defined, however this shouldn't be happening since the way the component is being dynamically loaded disables SSR.

I know this is an old JQuery library, but I have been able to make it work by including the script in normal HTML instead of Next. There is a React package alternative to this JQuery library but that is not the solution I am looking for as it is inferior in many ways design wise.

about 4 years ago · Juan Pablo Isaza
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