How to get the component corresponding to the current routing in DATA API? #10464
-
I am new to React-Router. I want to add a page cache to React-Router. To this end, I need to obtain the component corresponding to the current routing. By looking through the document, I found the |
Beta Was this translation helpful? Give feedback.
Answered by
tbontb-iaq
May 26, 2023
Replies: 1 comment
-
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 |
Beta Was this translation helpful? Give feedback.
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
I found a possible solution:
The
route
is typeof DATA APIRouteObject
.