Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-router path should support string | string[] #30158

Closed
2 of 4 tasks
rachitpsolanki opened this issue Oct 31, 2018 · 4 comments
Closed
2 of 4 tasks

react-router path should support string | string[] #30158

rachitpsolanki opened this issue Oct 31, 2018 · 4 comments

Comments

@rachitpsolanki
Copy link
Contributor

rachitpsolanki commented Oct 31, 2018

export interface RouteProps {
location?: H.Location;
component?: React.ComponentType<RouteComponentProps> | React.ComponentType;
render?: ((props: RouteComponentProps) => React.ReactNode);
children?: ((props: RouteComponentProps) => React.ReactNode) | React.ReactNode;
path?: string[] | string ;
exact?: boolean;
sensitive?: boolean;
strict?: boolean;
}

If you know how to fix the issue, make a pull request instead.

  • I tried using the @types/xxxx package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.
    • Authors: @....

@sergey-buturlakin @mrk21 @vasek17

@jtreminio
Copy link

jtreminio commented Oct 31, 2018

v 4.4.0 was recently released, has what you need: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/index.d.ts#L80

@rachitpsolanki
Copy link
Contributor Author

v 4.4.0 was recently released, has what you need: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/index.d.ts#L80

@jtreminio
Thank you!!

@jtreminio
Copy link

proptypes still complains, though. You can use the following to suppress the console warning: remix-run/react-router#5866 (comment)

@mrichmond
Copy link

why not just fix the propTypes?

Here's my slightly cleaner but still very "hacky" solution:

import { Route } from 'react-router-dom';
import { oneOfType, array, string } from 'prop-types';
Route.propTypes.path = oneOfType([array, string]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants