lbry-desktop/ui
infinite-persistence b733215c5f
PublishFile: fix render function violation (#1518)
* 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.
2022-05-19 10:41:32 -04:00
..
component PublishFile: fix render function violation (#1518) 2022-05-19 10:41:32 -04:00
constants Add ability to link to latest or current live channel file pages 2022-05-16 06:36:50 -04:00
contexts Category: Hide "Repost" from ContentType filter, except for WildWest 2022-04-25 08:49:46 -04:00
effects ClaimList: Factor out infinite-scroll and batch-resolve handling into an effect. 2022-05-16 07:57:24 -04:00
modal Fix crashing when uri has spaces 2022-05-02 09:39:01 -04:00
page Fix selector naming convention 2022-05-19 13:10:37 +08:00
redux Support stream updates via claim_id parameter (#1465) 2022-05-19 08:13:48 -04:00
scss Add bottom right desktop chat resize indicator 2022-05-18 14:53:17 -03:00
util Fix crash 2022-05-16 07:41:53 -04:00
analytics.js more analytics + fixes (#1476) 2022-05-17 10:47:44 -04:00
app.js refactor lbrytv web server 2019-11-11 13:27:29 -05:00
comments.js Remove custom comments server 2022-02-03 10:24:58 -05:00
i18n.js Add env to auto report new strings in console 2022-01-05 00:26:31 -08:00
index.jsx Re-design comment threads (#1489) 2022-05-16 06:22:13 -04:00
lbry.js Revert "Temporarily prevent invalid get calls until we figure it out" (#1529) 2022-05-18 20:37:53 -04:00
logWarningConsoleMessage.js new lbc icon 2020-09-29 17:12:32 -04:00
native.js working 2020-12-16 10:52:22 -05:00
reducers.js Support resume-able upload via tus (#186) 2021-11-10 13:16:16 -05:00
rewards.js Change logic for daily reward claiming to weekly 2021-12-23 02:40:58 -05:00
store.js Patch to restore position upon returning to video until more fully fleshed out fix can be introduced (#817) 2022-02-07 12:51:26 -05:00