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
Refactor Rifm into useRifm hook and Rifm component #93
Conversation
Happy to add some tests specifically for the hook if desired, but it didn't feel super vital as all the code paths in the hook are exercised by the existing render props tests.
|
There is a way to reduce the size. The source of problem here is rest operator |
@TrySound Can we after somehow measure the impact size of using hook only version having that Rifm export could be treeshaked? As with suggestion above hook only version can be smaller vs render props? |
843 -> 834 |
Great catch! I tried @TrySound's suggestion and it reduced the gzipped size to 861, an 18 bytes increase. Is that more acceptable @istarkov? I think it might also be worthwhile to consider a v2 that provides only a hook, since it's fairly trivial for users to build a Rifm render props component from a useRifm hook (i.e. the 2 lines implemented here), but as a user, I personally couldn't figure out any good ways to convert the Rifm component into a hook, hence this PR. But that's a much bigger decision that's outside of the scope of this PR. :) |
Hook only will be probably v1. But we will keep render prop for now to make soft upgrade without rewriting everything. |
Great! And additional createExec method createExecHook with hook inside instead of render function |
Also it will be good to add few hook version examples |
@istarkov I would just refactor original tests with hook version. Render prop is a thing wrapper without any logic. |
Possibly you are right, I have no strong opinion on this |
@lewisl9029 Upgrade readme with hook version please and we will merge. |
thanks! |
To address #38
Happy to add some tests specifically for the hook if desired, but it
didn't feel super vital atm as all the code paths in the hook are exercised
by the existing render props tests.
Also happy to help in updating docs as well.
I have these changes currently published as @lewisl9029/rifm@0.02 in case anyone wants to try it out.