Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

[WIP] Memoize refetch in useGet hook #188

Closed
wants to merge 2 commits into from
Closed

[WIP] Memoize refetch in useGet hook #188

wants to merge 2 commits into from

Conversation

owinter86
Copy link
Contributor

Why

Addresses #186, refetch is memoized against the same dependency array as the auto fetchData() effect within the package.

@owinter86
Copy link
Contributor Author

Sorry, I changed my train of thought a few times with this, I think refetch should not depend on anything and be referentially equal on first initialisation, but since the fetchData function is extracted out of the hook, I think I need to create two refetch function to ensure none of the data passed to _fetchData is stale, hence why there is refetch and refetchMemo.

@owinter86 owinter86 changed the title Memoize refetch in useGet hook [WIP] Memoize refetch in useGet hook Nov 26, 2019
@owinter86 owinter86 closed this Nov 27, 2019
@tonthanhhung
Copy link

@owinter86, Could you give some sort description why did you close this PR ?, I think it's quite helpful in many cases

@owinter86
Copy link
Contributor Author

owinter86 commented Jan 8, 2020

From what I recall, I closed this as its not a simple solution as I first thought (basic memoization of refetch), retry is returning the fetchData function which is abstracted out of the component, and relies on props and state to be passed to it as arguments, so retry will always need to be updated with the latest versions of state and props, and therefore will always update when fetching new data.

I felt as though the fetchData abstraction would need to be removed and rewritten, so it was to not rely on having those arguments passed to it, I am not sure that this would be in line with how this package was setup, and unfortunately did not have capacity to continue with the PR.

Thankfully the testing suite is nice and robust and caught out those issues identified.

There is probably a straight forward solution that I am missing, but this PR wont solve that. Thats why I closed it.

Sorry I couldn't help out more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants