-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize result object #26
Conversation
This makes it possible to use the return value from the hooks in this library as dependencies for other hooks.
fetchMore: fetchMoreAsync.execute, | ||
isEnd, | ||
}), | ||
[canFetchMore, fetchMoreAsync, isEnd] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchMoreAsync
is memoized so no need to check for its individual methods.
currentPromise, | ||
currentParams, | ||
] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that AsyncState.value
is never mutated, so the memo dependency is just .value
itself.
In #17 there's talk of memoizing the |
Hey @fabiosantoscode , thanks for this PR Unfortunately that does not look like something I'd like to merge. I don't think it's very important to guarantee to the user that the return value is memoized, as it does not look to me a good practice to use such big object as a dependency in the first place. You'd rather add to the dependency array individual properties you actually need in the effect (for example To me the current problem this library has is:
As |
You're completely right that execute should be more stable. However I'm not sure how to fix this, so it's probably best to close. |
ok, I'm going to handle everything myself when I have some time :) |
@slorber just checking here - pretty sure I ran into this issue, this is still an issue right? |
Still an issue yes and I don't think it's worth stabilizing the result object, because it will change anyway. You'd better use each returned attribute independently. I just made the "execute()" callback stable so you can use it in deps arrays, other callbacks were already stable In the future, I'd like to move to |
This makes it possible to use the return value from the hooks in this library
as dependencies for other hooks.
Closes #17