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 1 reply

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
0 replies
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

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