Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@types/react-router-config
Advanced tools
@types/react-router-config provides TypeScript definitions for the react-router-config package, which is used to configure routes in a React application. It helps developers by providing type safety and autocompletion for route configuration objects.
Route Configuration
Defines an array of route configurations, specifying the path, whether the route should be matched exactly, and the component to render.
const routes: RouteConfig[] = [
{
path: '/',
exact: true,
component: HomeComponent
},
{
path: '/about',
component: AboutComponent
}
];
Nested Routes
Allows defining nested routes within a parent route, enabling complex routing structures.
const routes: RouteConfig[] = [
{
path: '/',
component: App,
routes: [
{
path: '/home',
component: HomeComponent
},
{
path: '/about',
component: AboutComponent
}
]
}
];
Route Matching
Uses the matchRoutes function to match a given pathname against the route configuration, returning an array of matched routes.
import { matchRoutes } from 'react-router-config';
const branch = matchRoutes(routes, '/about');
console.log(branch);
react-router is the core routing library for React. It provides a more comprehensive set of routing features compared to react-router-config, including hooks, context, and more dynamic routing capabilities.
react-router-dom is a package that provides DOM bindings for React Router. It includes components like BrowserRouter and Link, which are essential for web applications. It is more feature-rich and flexible compared to react-router-config.
react-router-redux is a package that integrates React Router with Redux. It allows for managing router state within a Redux store, providing a more unified state management approach. It offers different functionalities compared to react-router-config, focusing on state management.
npm install --save @types/react-router-config
This package contains type definitions for react-router-config (https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-router-config.
// Type definitions for react-router-config 5.0
// Project: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config, https://github.com/reacttraining/react-router
// Definitions by: John Reilly <https://github.com/johnnyreilly>
// Mathieu TUDISCO <https://github.com/mathieutu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
import { RouteComponentProps, SwitchProps, match } from 'react-router';
import { Location } from 'history';
export interface RouteConfigComponentProps<Params extends { [K in keyof Params]?: string } = {}>
extends RouteComponentProps<Params> {
route?: RouteConfig | undefined;
}
export interface RouteConfig {
key?: React.Key | undefined;
location?: Location | undefined;
component?: React.ComponentType<RouteConfigComponentProps<any>> | React.ComponentType | undefined;
path?: string | string[] | undefined;
exact?: boolean | undefined;
strict?: boolean | undefined;
routes?: RouteConfig[] | undefined;
render?: ((props: RouteConfigComponentProps<any>) => React.ReactNode) | undefined;
[propName: string]: any;
}
export interface MatchedRoute<
Params extends { [K in keyof Params]?: string },
TRouteConfig extends RouteConfig = RouteConfig
> {
route: TRouteConfig;
match: match<Params>;
}
export function matchRoutes<
Params extends { [K in keyof Params]?: string },
TRouteConfig extends RouteConfig = RouteConfig
>(routes: TRouteConfig[], pathname: string): Array<MatchedRoute<Params, TRouteConfig>>;
export function renderRoutes(
routes: RouteConfig[] | undefined,
extraProps?: any,
switchProps?: SwitchProps,
): JSX.Element;
These definitions were written by John Reilly, and Mathieu TUDISCO.
FAQs
TypeScript definitions for react-router-config
The npm package @types/react-router-config receives a total of 276,045 weekly downloads. As such, @types/react-router-config popularity was classified as popular.
We found that @types/react-router-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.