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

474
Vistas
React.js i have Bug in prod but not in dev mode, can you help me

I've been having a problem for 3 days now, and I don't really understand what can cause this bug, can you help me?

Here is the problem, I have created a small game(react.js) where 5 cards are displayed at each reload, these 5 cards have a score of points each which are cumulated each time, which gives a score of all the cards, then the score of each "hand" which is cumulated.

In development mode, everything works correctly, but if I build and put it on a cdn (netlify), the score logic doesn't work...

Prod link (bug) : https://are-you-lucky-game.netlify.app/

Github repo link (dev mode work fine) : https://github.com/rodolphe37/random-playing-card-tuto/tree/step-3-final

I think the problem may be coming from over here:

In my console on render (in dev)

score: undefined
classment from ScoreForm {pts: 0, name: ''}
scoreArray (5) [3, 7, 10, 15, 2]
classment from center Page {pts: 0, name: ''}
classment from state {pts: 0, name: ''}
classment from session  {pts: 0, name: ''}

score: undefined
classment from ScoreForm {pts: 0, name: ''}
scoreArray (5) [3, 7, 10, 15, 2]
classment from center Page {pts: 0, name: ''}
classment from state {pts: 0, name: ''}
classment from session  {pts: 0, name: ''}

score: 0
classment from ScoreForm {pts: 37, name: ''}
score: 37

in dev, my component is rendered several times (3 or 4 i think), and at the last render, the info is there.

In my Console (prod mode)

score: undefined
classment from ScoreForm {pts: 0, name: ''}
scoreArray (5) [5, 25, 3, 6, 1]
classment from center Page {pts: 0, name: ''}
classment from state {pts: 0, name: ''}
classment from session  {pts: 0, name: ''}
score: 0
classment from ScoreForm {pts: 0, name: ''}``

In production, my component is rendered two time I think, so my values are not there.

How can I make sure that my info (it comes from sessionStorage) is present at the first render of each component?

If you have ever encountered this kind of bug, or if you think you have a solution for me, I'm interested.

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I can see in your repo that you are using browserslist in package.json This is common in react-create-app as this library will bundle your code based on the configuration that is provided. Notice that you have two different configurations for development and production, try using the same config you have in development also for producttion object, this should fix your issue.

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