Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@jcoreio/react-router-apply-middleware

Package Overview
Dependencies
Maintainers
8
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jcoreio/react-router-apply-middleware

Composable middleware for React Router

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
8
Created
Source

React Router Apply Middleware

Compose behavior in the render lifecycle of React Router apps.

A name other than "middleware" would be awesome, I just can't think of one. Please suggest.

Installation

npm install react-router-apply-middleware

Usage

import applyRouterMiddleware from 'react-router-apply-middleware'
import { useAsyncProps } from 'react-router-async-props'
import { useRelativeLinks } from 'react-router-relative-links'
import { useNamedRoutes } from 'react-router-named-routes'
import routes from './routes'

const renderWithMiddleware = applyRouterMiddleware(
  useAsyncProps(),
  useRelativeLinks(),
  useNamedRoutes(routes)
)

render(<Router render={renderWithMiddleware} routes={routes}/>, el)

Writing Middleware

For now you'll have to look at the tests, it's a little bit tricky. As soon as the middleware libs I'm working on are updated, I'll come add some notes here about how to do it.

Hopefully we'll end up with stuff like:

useRelay(rootId)
useAlt()
useTransit()
useGroundControl(store)
useScrollBehavior()

etc.

Keywords

react

FAQs

Package last updated on 22 Dec 2017

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