Repository navigation
Data Context #11565
Replies: 7 comments 10 replies
|
I prefer this one: import { LoaderFunctionArgs } from 'react-router';
type Vars = {
db: OutDb;
}
function DbMiddleware({ context, request }: LoaderFunctionArgs<Vars>) {
let db = getDBFromRequest(request)
context.set('db', db);
}
// get a context in a loader
export async function loader({ context }: LoaderFunctionArgs<Vars>) {
let db = context.get('db')
// ...
}We don't need to import runtime code for type systems, Type System should not be invaded by runtime code. |
|
What will happen on Remix/RRv7 when |
|
When run on Cloudflare Pages/Workers, will a React Router 'Data Context' be a per-request instance, or will it be a global/potentially shared across multiple requests? (the latter behaviour would match |
|
What's the status of this? I'm looking to set values to a context but can't find |
|
Api is a bit confusing, I wanted to do auth before loaders in middleware: But got an error I did a refactoring to make it work, but this is a bit counter-intuitive: Can we expose response in middleware without calling loaders to make it a bit simpler? |
|
Is there any inbuilt way of accessing data through store like in zustand in react router?, I'm using context in middleware to store permissions and access in different route but eventually doing permission props drilling |
Uh oh!
There was an error while loading. Please reload this page.
Data context allows you to create a value in one place and share it across loaders, actions, and middleware.
All reactions