
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@pojo-router/core
Advanced tools
A hook based machanism to convert a string (i.e. a path) into metadata.
Define your metadata in a provider component.
import React from 'react';
import PojoRouter from 'pojo-router';
const namedPaths = {
page1: '/page1',
page2: { path: '/page2', sensitive: true },
page3: { path: '/page3/:id' },
};
const routes = [
{ name: 'page1', abc: 123 },
{ name: 'page2', abc: 456 },
{ name: 'page3', abc: 789 },
{ name: '/page4', abc: 0 }
];
const notFound = { nothing: true };
const Router = ({ children }) => (
<PojoRouter namedPaths={namedPaths} routes={routes} notFound={notFound}>
{ children }
</PojoRouter>
);
type Props = {
namedPaths: Record<string, string | NamedPath>;
routes: readonly Route[];
notFound: AnyIfEmpty<DefaultRoutePojo>;
};
class RouteController {
constructor({ namedPaths, routes, notFound }: Props);
readonly notFound: AnyIfEmpty<DefaultRoutePojo>;
readonly pathBuilders: Record<string, PathFunction>;
getMatchedRoutes(pathToMatch: string): any;
buildPath(pathOrPathName: string, pathData?: object): void;
}
This is the passed in notFound object.
Gets all routes matching the passed path.
Given a named route (or route string if none is defined), this returns a function that will generate a matching string, including populating the dynamic variables. E.g. for a route like /entity/:id
an outbound routing function like entityPath({ id: 123 })
will generate /entity/123
.
controller.buildPath('entity', { id: 123 })
Within your child component, use one of the hooks.
Given a path, this returns all the metadata for routes that match.
Get current location
Return the RouteController that can be used for computations
FAQs
A React hooks library to associate metadata to a path
The npm package @pojo-router/core receives a total of 30 weekly downloads. As such, @pojo-router/core popularity was classified as not popular.
We found that @pojo-router/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.