-
Hi every one and thank you for this amazing framework !! To explain my question I provide a minimal example where I load data from two different sources
// app/routes.ts
import { type RouteConfig, index, route } from "@react-router/dev/routes";
export default [
index("routes/home.tsx"),
route("api", "routes/api.ts"),
] satisfies RouteConfig; My principal route // app/routes/home.tsx
import { useEffect } from "react";
import type { Route } from "./+types/home";
import { href } from "react-router";
export function loader() {
return {
dateFromLoader: new Date(),
};
}
export default function Home({ loaderData }: Route.ComponentProps) {
useEffect(() => {
fetch(href("/api"))
.then((res) => res.json())
.then((fetchData) => {
console.log(loaderData, fetchData);
});
});
return <div>Home</div>;
} my route // app/routes/api.ts
export function loader() {
return Response.json({
dateFromResourceRoute: new Date(),
});
}
I didn't find any mention of that in the doc. and I wonder if these methods are exported from the source code to be used for my own logic ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It uses turbo-stream package from Jacob Ebey |
Beta Was this translation helpful? Give feedback.
-
Thank you @sergiodxa ! |
Beta Was this translation helpful? Give feedback.
It uses turbo-stream package from Jacob Ebey
https://github.com/jacob-ebey/turbo-stream