react-request icon indicating copy to clipboard operation
react-request copied to clipboard

Redundant `render` run with outdated state

Open edoroshenko opened this issue 7 years ago • 3 comments

If I render the same Fetch with new url, first I get it's children rendered with previous state (old url, old data, etc.) It looks like the problem is known: https://github.com/jamesplease/react-request/blob/eca89d5fe79bd546a0641b6443415b722e3f6ec3/src/fetch.js#L107 It feels that it would be simple to fix it by updating Fetch state in componentWillReceiveProps hook. @jamesplease what's your opinion?

edoroshenko avatar Sep 24 '18 11:09 edoroshenko

Thanks for the issue @edoroshenko !

It feels that it would be simple to fix it by...

I sometimes think something will be simple about this library, and then it surprises me. It's a real monster, honestly.

I'm open to using cWRP. In fact, it used to work that way. If you'd like to revert it, go ahead and make a PR, but you'll need to dodge some of the bugs that I fixed by making the swap.

If you decide to take this on, referencing this PR and this issue may be useful to you.

Good luck!

jamesplease avatar Sep 24 '18 15:09 jamesplease

Hi @jamesplease thanks for the details, they would be definitely helpful!

edoroshenko avatar Sep 25 '18 14:09 edoroshenko

Just wanted to mention that componentWillReceiveProps was deprecated in React 16.3 https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops

bghveding avatar Sep 25 '18 16:09 bghveding