-
Notifications
You must be signed in to change notification settings - Fork 163
Proposal for react-meteor-hooks
#263
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
Conversation
@leoc: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
react-meteor-hooks
react-meteor-hooks
react-meteor-hooks
react-meteor-hooks
5a7620f
to
98f1e6a
Compare
Looks pretty good. Couple of things though: Maybe use array to define multiple subscriptions for Add a general |
This looks really promising, i already opened an issue to propose using hooks before noticing your PR. |
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.
update react version to latest stable
@@ -2,7 +2,7 @@ import { checkNpmVersions } from 'meteor/tmeasday:check-npm-versions'; | |||
|
|||
checkNpmVersions({ | |||
react: '16.7.0-alpha.0', |
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.
It would be good to set the react version to current stable in this case 16.8.3
I would think the most direct analog for |
this implementation not working as expected. |
This seems like a good idea for the most part. One potential problem I see is that there is no way (at least I can't think of any) to access the subscription EDIT:
|
Arthur Leonard Andersen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
1 similar comment
Arthur Leonard Andersen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
closing because of [email protected] #273 |
I played around a little with
react-hooks
.This is what I came up with. I would love to discuss this solution.
I created a little sample project here https://github.com/leoc/react-meteor-hooks-example
Unfortunately the test script does not exist. But I would love to write tests for these hooks.
Hooks
useMeteorSubscription
It takes all arguments you would put into
Meteor.subscribe
and runsthe subscription and
ready()
checks in auseEffect
and returns thevalue of a state hook for
ready()
.useMeteorData
This function takes a function as first parameter and runs that as an
effect hook within the meteor tracker. The second parameter is an
array of inputs that influence the effect hook.
It returns the value of the state hook that represents the return
value of the given function. This can either be an object to be
destructured later or a single value (array of collection documents or
single collection document).
Usage
This package exports the hooks
useMeteorSubscription
anduseMeteorData
.