App performance review
See original GitHub issueWorking on the issue 501, I had to understand how the app is propagating the TX list in order to show a new filed origin
.
I found that src/routes/index.js renders this:
const Safe = React.lazy(() => import('./safe/container'))
…
<Route path={SAFE_ADDRESS} component={withTracker(Safe)} />
So far so good, then Safe, in componentDidMount
using an interval:
const TIMEOUT = process.env.NODE_ENV === 'test' ? 1500 : 5000
fetches an insane amount of that from the API and propagate it to the <Layout
through props.
After that, Layout in the render, using react-router handles the content for each tab:
Here we have 2 huge problems:
- No all tabs need all the data fetched in
<Safe
component. - Sending all the props at
<Layout
level, produces a re-render of the whole app eachTIMEOUT
interval.
My proposal We can solve this problem pretty simple.
- Create
a Redux storean entry in the redux store per each type of “data”, Tokens, Transactions, Currencies, AddressBook, etc. <Safe
, instead of passing all the fetched data to<Layout
as props, it updates the store from point 1.- Then, each Tab subscribes to that store for the data it really needs, for example, Balance tab, will only subscribe to Tokens and not Transactions.
Refactor Needed The refactor should be really simple to implement, it’s just to move some props from Layout to the particular components and… subscribe these components to the redux store created at point 1.
Improvement
-
With this solution, the whole app won’t render each 1.5 seconds in dev or 5 seconds in production. Only the needed components will render.
-
Also, the development will be simplified because we won’t need to pay attention in side-effects produced by the constants re-renders.
-
spiritual peace
GOAL: Create multiple issues focusing each of them on a specific performance issue.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top GitHub Comments
I mean a key per entity in the current store
I strongly agree with this proposal, Also I think it would be also useful some benchmarking as Mikhail suggested 😃 but I think that maybe we would need to get rid of immutable js in order to achieve that as already mentioned
Would be nice if we can do a small experiment with this to see what we can do and estimate it better