Created
April 5, 2024 19:40
-
-
Save PaulieScanlon/b2538b0e6df41210d3e5c85b8ee8c786 to your computer and use it in GitHub Desktop.
Example Remix Route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/routes/_index.jsx | |
import { useLoaderData } from '@remix-run/react'; | |
import { json } from '@remix-run/node'; | |
import ParentComponent from '../components/parent-component'; | |
const Page = () => { | |
const { data } = useLoaderData(); | |
return <ParentComponent data={data} />; | |
}; | |
export const loader = async () => { | |
const response = await fetch('https://api.github.com/repos/remix-run/remix'); | |
const data = await response.json(); | |
return json({ | |
data, | |
}); | |
}; | |
export default Page; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment