Skip to content
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

Rename useFacetEffect to useFacetLayoutEffect and add a new useFacetEffect #30

Merged
merged 6 commits into from
Jan 28, 2022

Conversation

jacobbergdahl
Copy link
Contributor

@jacobbergdahl jacobbergdahl commented Jan 27, 2022

The name of the useFacetEffect function is slightly misleading in the current implementation, as it is actually using React's useLayoutEffect as an underlying function. Thus, we have renamed the function to useFacetLayoutEffect and added a new function called useFacetEffect in its place that actually uses React's useEffect.

We have updated the documentation to reflect this change in a separate pull request (#31).

@jacobbergdahl
Copy link
Contributor Author

There is now a handful of code that is duplicated between useFacetEffect and useFacetLayoutEffect. @MartinMoe and I had a discussion about whether we should extract parts of the code into shared functions. We could even combine certain tests or make parts of the implementation of the tests reusable between useFacetEffect and useFacetLayoutEffect.

We ended up deciding not to do so for now, however. We decided to prioritized keeping the code easily readable and to keep the logic between different functions completely separated, even if it is similar.

Copy link
Contributor

@xaviervia xaviervia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@@ -6,7 +6,7 @@ module.exports = {
'react-hooks/exhaustive-deps': [
'error',
{
additionalHooks: '(useFacetEffect|useFacetMap|useFacetMemo|useFacetCallback)',
additionalHooks: '(useFacetLayoutEffect|useFacetEffect|useFacetMap|useFacetMemo|useFacetCallback)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jacobbergdahl jacobbergdahl merged commit 5de75b8 into main Jan 28, 2022
@jacobbergdahl jacobbergdahl deleted the enhancement-update-use-facet-effect branch January 28, 2022 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants