question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initialize the client with a predictable Redux state object

See original GitHub issue

For sanity, we should initialize the client (i.e. rendered HTML) with a predictable Redux state object.

For QA: This change could affect the entire app but only for the first page load. Please test as much as possible with this approach:

  • Load the site, navigate to another page
  • Click the browser refresh button
  • Make sure the page looks correct after refresh
  • Navigate somewhere else, click refresh, verify, and repeat…

How is the current Redux state object unpredictable, you ask? Well, let me begin by mourning the hours of my life lost to this bug. Thanks, let’s continue. You can see it in action like this:

  • Go to https://addons-dev.allizom.org/en-US/firefox/addon/icloud-test-dev/ in Chrome so you can use Redux Devtools. Be sure to load the URL directly instead of navigating there from another page.
  • With Redux Devtools, select the @@INIT action and open the State tab to see the initial state that the page was loaded with.
  • Open up addonsByAuthors and you should see something like: loadingFor: { ValentinaDDD-extension: true }.

This means the client will think it’s in a loading state yet nothing will ever load!

If you use the logger from https://github.com/mozilla/addons-frontend/pull/6724 then you’ll see how the final server render dispatches FETCH_ADDONS_BY_AUTHORS just quick enough to modify state before ServerHtml renders its HTML.

Funny enough, the AddonsByAuthors component does not check if data has already been loaded or is in the process of loading before beginning to load data. Hmm, I wonder if there is a trail of tears behind that decision! All other components would have trouble here because it would be impossible to know if it is safe to begin loading data or not.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ioanarusiczkicommented, Oct 24, 2018

@willdurand Ok, I will re-check for other pages too and return with the test results.

1reaction
willdurandcommented, Oct 25, 2018

I changed the milestone because the patch has landed after this week’s tag.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux Fundamentals, Part 3: State, Actions, and Reducers
The official Redux Fundamentals tutorial: learn how reducers update state in response to actions.
Read more >
React Redux: An Intro to The Leading State Management ...
This blog post highlights why Redux is one of the leading state management solutions for React, and how the React Redux library helps...
Read more >
Redux in React Native: How to Install? with Examples
“Store” holds the entire state of the application state as a plain javascript object. The store is created with the help of reducers,...
Read more >
React, Redux, and Immutable.js: Ingredients for Efficient UI
All data in Redux application lives inside a single store object and we can look at the ... Redux is an open-source JavaScript...
Read more >
React Router with Redux: Understanding navigation state
Redux is a predictable state container designed to help you write JavaScript apps that behave consistently across client, server, and native ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found