Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// matchPath
const match: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId",
exact: true,
strict: false
});
const match2: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId"
});
const match3: null | Match = matchPath("/the/pathname");
// $ExpectError
matchPath();
// $ExpectError
const matchError: string = matchPath("/the/pathname", {
path: "the/:dynamicId"
});
const Unrouted: React$ComponentType<{|
...ContextRouter,
someProp: string
|}> = () => <span>;
const Routed1: React$ComponentType<{| someProp: string |}> = withRouter(
Unrouted
);
// $ExpectError: This error bubbles up from the assignment in Routed2.
const Unrouted2: React$ComponentType<{|
...ContextRouter,
someProp: string</span>
}}
>
About
;
// $ExpectError
;
// DeepLinking
;
// AndroidBackButton
;
// matchPath
const match: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId",
exact: true,
strict: false
});
const match2: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId"
});
const match3: null | Match = matchPath("/the/pathname");
// $ExpectError
matchPath();
// $ExpectError
const matchError: string = matchPath("/the/pathname", {
path: "the/:dynamicId"
});
// $ExpectError
;
// DeepLinking
;
// AndroidBackButton
;
// matchPath
const match: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId",
exact: true,
strict: false
});
const match2: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId"
});
const match3: null | Match = matchPath("/the/pathname");
// $ExpectError
matchPath();
// $ExpectError
const matchError: string = matchPath("/the/pathname", {
path: "the/:dynamicId"
});
const Unrouted: React$ComponentType<{|
...ContextRouter,
someProp: string
|}> = () => <span>;
</span>
// DeepLinking
;
// AndroidBackButton
;
// matchPath
const match: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId",
exact: true,
strict: false
});
const match2: null | Match = matchPath("/the/pathname", {
path: "/the/:dynamicId"
});
const match3: null | Match = matchPath("/the/pathname");
// $ExpectError
matchPath();
// $ExpectError
const matchError: string = matchPath("/the/pathname", {
path: "the/:dynamicId"
});
const Unrouted: React$ComponentType<{|
...ContextRouter,
someProp: string
|}> = () => <span>;
const Routed1: React$ComponentType<{| someProp: string |}> = withRouter(
Unrouted
);</span>
React.Children.forEach(children, element => {
if (!React.isValidElement(element)) return;
const { path: pathProp, exact, strict, sensitive, from } = element.props;
const path = pathProp || from;
if (match == null) {
child = element;
match = path == null ? {} : matchPath(location.pathname, { path, exact, strict, sensitive });
}
});