use-autorun
v1.0.4
Published
React hook for Meteor's Tracker.autorun
Downloads
2
Readme
use-autorun
React hook for Meteor's Tracker.autorun
. Use this hook to provide Tracker reactivity to your functional components:
function ExampleComponent(props) {
// document will update whenever it changes in Minimongo
const document = useAutorun(() => {
Meteor.subscribe('mySubscription');
return MyCollection.findOne(myDocumentID);
});
// Before the subscription is ready, document will be null
if (!document) {
return null;
}
return (
<div>
{document._id}
</div>
);
};