sheaivey / react-axios

Axios Components for React with child function callback
MIT License
180 stars 20 forks source link

Add failing test case demonstraiting bad setState() call. #12

Closed binki closed 7 years ago

binki commented 7 years ago

This failing test case reproduces the error I reported in #9.

The logic error is that the debounce will call the wrapped function and the wrapped function does not check if the component has been unmounted in the meantime.

This is the repro for #9. The test is expected to fail, as I have not attempted to fix the issue. Please let me know if this repro makes the issue I reported in #9 clear or not.

sheaivey commented 7 years ago

Can you resolve these conflicts then let me know if the latest changes around setState() have fixed this issue in v1.0.3?

The following lines address issue #9 Don't start any new requests after componentWillUnmount() https://github.com/sheaivey/react-axios/blob/master/src/components/Request.js#L55

Don't set state after async success and error https://github.com/sheaivey/react-axios/blob/master/src/components/Request.js#L76 https://github.com/sheaivey/react-axios/blob/master/src/components/Request.js#L80

binki commented 7 years ago

@sheaivey I rebased and it looks like it’s passing at least the tests I added for the PR. Thanks!

sheaivey commented 7 years ago

Great, thanks for the contribution!