Skip to content

How to make Route.LoaderArgs context type safe? #12859

Closed Answered by sergiodxa
davidbielik asked this question in Q&A
Discussion options

You must be logged in to vote

The context object is typed with the interface AppLoadContext, you can overwrite it using declaration merging, in a .ts or .d.ts file do

import "react-router";
declare module "react-router" {
  interface AppLoadContext {
    // add things here
  }
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@davidbielik
Comment options

@gustavopch
Comment options

@sergiodxa
Comment options

Answer selected by davidbielik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants