mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
chore: added useSubscribe typescript skeleton
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import React from 'react';
|
||||
import { useTracker } from 'meteor/react-meteor-data';
|
||||
import { LinksCollection, Link } from '../api/links';
|
||||
import React from "react";
|
||||
import { useFind, useSubscribe } from "meteor/react-meteor-data";
|
||||
import { LinksCollection, Link } from "../api/links";
|
||||
|
||||
export const Info = () => {
|
||||
const links = useTracker(() => {
|
||||
return LinksCollection.find().fetch();
|
||||
});
|
||||
const isLoading = useSubscribe("links");
|
||||
const links = useFind(() => LinksCollection.find());
|
||||
|
||||
if (isLoading()) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
const makeLink = (link: Link) => {
|
||||
return (
|
||||
<li key={link._id}>
|
||||
<a href={link.url} target="_blank">{link.title}</a>
|
||||
<li key={ link._id }>
|
||||
<a href={ link.url } target="_blank">{ link.title }</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -18,7 +21,7 @@ export const Info = () => {
|
||||
return (
|
||||
<div>
|
||||
<h2>Learn Meteor!</h2>
|
||||
<ul>{links.map(makeLink)}</ul>
|
||||
<ul>{ links.map(makeLink) }</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user