Skip to content

How can I access the context from the component function? #1628

Answered by TkDodo
sawa-ko asked this question in Q&A
Discussion options

You must be logged in to vote

components that render on a route don't receive any props. You get loader data with useLoaderData(). You get path params with useParams(). And you can get context with useMatches() and then access .context. It's even shown in your image ...

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
2 replies
@mindaugasb-isense
Comment options

@schiller-manuel
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@TkDodo
Comment options

Answer selected by SeanCassiere
@dylanhu7
Comment options

@TkDodo
Comment options

@dylanhu7
Comment options

@thomastvedt
Comment options

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