Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-routes-dub
Advanced tools
Readme
Stupid-easy React routing for the browser in 200 lines of code and with a single dependency.
That single dependency is important. path-to-regexp is used by Express to parse path strings, and now you can use it for your client-side routes.
Why you might use it:
Why you might skip it:
yarn add react-routes-dub
or
npm install --save react-routes-dub
Define your routes with a single file:
// routes.js
import routesDub from 'react-routes-dub';
export const {
DubProvider,
Link,
Route,
pathFor
} = routesDub([
{
name: 'home',
pattern: '/'
},
{
name: 'pet',
pattern: 'pets/:petId',
onEnter: ({ params }) => {
loadPetData(params.petId);
},
routes: [
{
name: 'toys',
pattern: 'toys'
}
]
}
]);
Now everything you need to begin routing is immediately available.
// app.jsx
import React, { Component } from 'react';
import { DubProvider, Link, Route } from './routes';
class App extends Component {
render () {
return (
<DubProvider>
<Link to='home'>Home</Link>
<Link to='pet' params={ { petId: 'dog-1' } }>See Dog One</Link>
<Link to='pet' params={ { petId: 'dog-2' } }>See Dog Two</Link>
<Link to='pet.toys' params={ { petId: 'dog-1' } }>See Dog One's Toys</Link>
<Route is='home'>
<p>Welcome home.</p>
</Route>
<Route is='pet'>
{ ({ params }) => {
// route parameters are available here
return (
<p>Pet ID here: { params.petId }</p>
)
} }
</Route>
<Route is='pet.toys'>
<p>Pet Toys!</p>
</Route>
</DubProvider>
);
}
}
That's it! You're done.
See ./test for a complete example.
FAQs
Stupid-easy React routing for the browser in 200 lines of code and with a single dependency.
The npm package react-routes-dub receives a total of 1 weekly downloads. As such, react-routes-dub popularity was classified as not popular.
We found that react-routes-dub demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.