Skip to content

How to get the component corresponding to the current routing in DATA API? #10464

Closed Answered by tbontb-iaq
tbontb-iaq asked this question in Q&A
Discussion options

You must be logged in to vote

I found a possible solution:

import { UNSAFE_RouteContext as RouteContext } from "react-router-dom";
import { useContext } from "react";

const routeContext = useContext(RouteContext);
const route = routeContext.matches[0].route;

The route is typeof DATA API RouteObject.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tbontb-iaq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant