Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

471
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!