b733215c5f
* PublishFile: fix render function violation Per doc: > A React component should not cause side effects in other components during rendering. Even in own render function (allowed to call), it should be avoided as it could cause infinite loops. * PublishFile: fix useEffect infinite loop due to bad dependency ## Issue One of the effects was adding an internal wrapper function as a dependency. As this is a functional component, the wrapper is re-created on every render and would spark the effect. That effect also updates redux (depending on the code path), so we end up in a loop. ## Change 1 Two options to fix the dependency: 1. Just remove the wrappers from the list, since we "know" it is essentially the same function (i.e. it's not function-variable that could point to something else at runtime). 2. Peek into the wrapper and determine what are the actual dependencies (usually props or data derived from props). Solution 2 is the norm. Aside: wrappers are usually the root-cause of incorrect dependencies, because they mask away the actual code. Need to always peek into it. ## Change 2 Next, change the dispatch-to-props map from function version to object version so that we have stable references to the actions. The object version is also preferred when we don't need to make any customizations to the actions. |
||
---|---|---|
.. | ||
component | ||
constants | ||
contexts | ||
effects | ||
modal | ||
page | ||
redux | ||
scss | ||
util | ||
analytics.js | ||
app.js | ||
comments.js | ||
i18n.js | ||
index.jsx | ||
lbry.js | ||
logWarningConsoleMessage.js | ||
native.js | ||
reducers.js | ||
rewards.js | ||
store.js |