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

Remove need for memoization in accordion #255

Merged
merged 1 commit into from
Feb 3, 2021
Merged

Conversation

sarayourfriend
Copy link
Collaborator

By moving action functions into module level functions we remove the need to memoize them. Their signature expands but not to the point of being unweildy.

Just an interesting approach to this problem, may or may not be something we adopt.

https://twitter.com/dan_abramov/status/1125774170154065920

@vercel
Copy link

vercel bot commented Feb 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/itsjonq/g2/h8y1gxat0
✅ Preview: https://g2-git-add-context-module-funcs.itsjonq.vercel.app

Copy link
Owner

@ItsJonQ ItsJonQ left a comment

Choose a reason for hiding this comment

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

🚀 from me! This is an interesting pattern :). I can see the benefits from it.
I think the requirement of passing dispatch as an argument is okay, as long as it's contained within the parent component or hook.

How it's used here is 👍

I think where it would be cumbersome would be if the hook consumer would need to "assemble" the callback methods together when they want to use it (i.e. manually passing in dispatch as an arg).

For example, for a Reakit like workflow where the consumer creates components from hooks, assembling the callback methods + dispatch would feel verbose.

@ItsJonQ ItsJonQ merged commit 95b5bde into main Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
components enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants