Skip to content
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

TUTORIAL: useResource now has a task #1151

Merged
merged 3 commits into from
Nov 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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