fossar / selfoss

multipurpose rss reader, live stream, mashup, aggregation web application
https://selfoss.aditu.de
GNU General Public License v3.0
2.35k stars 343 forks source link

client: Fix state handling #1458

Closed jtojnar closed 11 months ago

jtojnar commented 11 months ago

Some state action dispatchers in class components would refer to this.state property when given a function as the action argument. Since React 18 automatically batches state updates, calling such broken dispatcher after another dispatch in the same render might discard the changes performed by the earlier dispatcher because this.state would contain the state before the render started.

Let’s pass a function to this.setState and use the state argument provided by the dispatch to always get the freshest state.

Fixes: https://github.com/fossar/selfoss/issues/1454

netlify[bot] commented 11 months ago

Deploy Preview for selfoss canceled.

Name Link
Latest commit b373740b1ff1b9578b1773c0f30a3b874d5df0a4
Latest deploy log https://app.netlify.com/sites/selfoss/deploys/64c553ffdc092b0008105028