Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
When I was searching for information about react, I saw
RouteComponentProps
like
import { RouteComponentProps } from 'react-router-dom';
const ~~~: React.FC<RouteComponentProps>
class BookingSiteOverview extends React.Component<RouteComponentProps<{}>
So I searched RouteComponentProps
, but given information is too fragmented. RouteComponentProps
is mentioned in Q&A only briefly.
I want to know what is this. What is it for and how to use it?
Please give me advice.
RouteComponentProps
looks to be a Typescript interface definition of react-router-dom's route-props.
The RouteComponentProps
prop-types definition may've been part of react-router-dom but isn't currently exported. I found the Typescript export in Definitely Typed.
export interface RouteComponentProps<Params extends { [K in keyof Params]?: string }> {
match: match<Params>;
location: H.Location;
history: H.History;
staticContext?: any;
This is just the way to define the react propTypes in Typescript, via interfaces.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.