Skip to content

Commit

Permalink
docs(tutorial): useResource now has a task (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmon committed Nov 20, 2022
1 parent 8812c6e commit a0a52ca
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default component$(() => {
org: 'BuilderIO',
});

// Use useResource$() to set up how the data is fetched from the server.
// See the example for Fetching Data in the text on the left.
const reposResource = useResource$<string[]>(({ track, cleanup }) => {
// We need a way to re-run fetching data whenever the `github.org` changes.
// Use `track` to trigger re-running of the this data fetching function.
Expand All @@ -32,20 +34,17 @@ export default component$(() => {
/>
</span>
<div>
<Resource
value={reposResource}
onPending={() => <>Loading...</>}
onRejected={(error) => <>Error: {error.message}</>}
onResolved={(repos) => (
{/* Use <Resource> to display the data from the useResource$() function. */}
{/* To help, here's a callback function to display the data on resolved. */}
{/* (repos) => (
<ul>
{repos.map((repo) => (
<li>
<a href={`https://github.com/${github.org}/${repo}`}>{repo}</a>
</li>
))}
</ul>
)}
/>
) */}
</div>
</div>
);
Expand Down

0 comments on commit a0a52ca

Please sign in to comment.