Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-router5

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router5

router5 helpers for React

  • 8.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-11.32%
Maintainers
1
Weekly downloads
 
Created
Source

npm version

react-router5

Installation

Install module `react-router5:

yarn add react-router5
# or
npm install --save react-router5

Demos and examples

Codesandbox link

Provider

  • RouterProvider: adds your router instance and router state in context.
const AppWithRouter = (
  <RouterProvider router={router}>
    <App />
  </RouterProvider>
)

Connecting components

You can connect your components using three different methods:

  • Higher-order components: withRouter, withRoute and routeNode
  • Render props: Router, Route and RouteNode
  • Hooks: useRouter, useRoute and useRouteNode
HoCRender propHook
Use your router instancewithRouterRouteruseRouter
Connect to routing statewithRouteRouteuseRoute
Connect to a route noderouteNodeRouteNodeuseRouteNode
  • BaseLink: a component to render hyperlinks. For a full list of supported props, check the source!
  • Link: Link is withRouter and BaseLink composed together
  • ConnectedLink: same as Link, except it re-renders on a route changes.
import React from 'react'
import { Link } from 'react-router5'

function Menu(props) {
  return (
    <nav>
      <Link routeName="home">Home</Link>

      <Link routeName="about">About</Link>
    </nav>
  )
}

export default Menu

Keywords

FAQs

Package last updated on 19 Mar 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc