添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
豪气的双杠  ·  vscode ...·  1 年前    · 
率性的山楂  ·  android ...·  1 年前    · 
霸气的大蒜  ·  django restframework ...·  1 年前    · 
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.

If you need to use the History type in TypeScript, it needs to be imported from a library that react-router-dom uses: history – Jonathan Tyson Aug 11, 2021 at 15:10

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.