All Projects → pshrmn → Rrc

pshrmn / Rrc

Licence: mit
React Router v4 helper components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Rrc

Now Ui Kit React
React version of Now UI Kit by Creative Tim
Stars: ✭ 90 (-19.64%)
Mutual labels:  react-router
Npm Registry Browser
Browse the npm registry with an SPA made in React, with full dev workflow.
Stars: ✭ 97 (-13.39%)
Mutual labels:  react-router
React Login
A client side implementation of authentication using react.js for my blog on medium. This is the second part of my previous blog on how to implement scalable node.js server.
Stars: ✭ 105 (-6.25%)
Mutual labels:  react-router
Award
⚙基于react的服务端渲染框架
Stars: ✭ 91 (-18.75%)
Mutual labels:  react-router
Spring Security React Ant Design Polls App
Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
Stars: ✭ 1,336 (+1092.86%)
Mutual labels:  react-router
React Antd Admin
一個简洁的 antd-react-admin 应用 -- React + Antd 后台管理系统
Stars: ✭ 99 (-11.61%)
Mutual labels:  react-router
React Redux Saucepan
A minimal and universal react redux starter project. With hot reloading, linting and server-side rendering
Stars: ✭ 86 (-23.21%)
Mutual labels:  react-router
Road Beyond React App
🌈 The Road beyond React - Thing you can use after learning plain React.js
Stars: ✭ 108 (-3.57%)
Mutual labels:  react-router
Redux Cnode
react+react-router+redux+es6+antd-mobile+webpack版本的Cnode
Stars: ✭ 96 (-14.29%)
Mutual labels:  react-router
React Bootstrap Webpack Starter
ReactJS 16.4 + new React Context API +react Router 4 + webpack 4 + babel 7+ hot Reload + Bootstrap 4 + styled-components
Stars: ✭ 103 (-8.04%)
Mutual labels:  react-router
React Antd Admin
用React和Ant Design搭建的一个通用管理后台
Stars: ✭ 1,313 (+1072.32%)
Mutual labels:  react-router
Molecule
⚛️ – :atom: – ⚛️ Boilerplate for cross platform web/native react apps with electron.
Stars: ✭ 95 (-15.18%)
Mutual labels:  react-router
Libreact
NO LONGER MAINTAINED - SEE https://github.com/streamich/libreact INSTEAD
Stars: ✭ 100 (-10.71%)
Mutual labels:  react-router
React Atomic Structure
Basic Structure for React app following Atomic Design
Stars: ✭ 89 (-20.54%)
Mutual labels:  react-router
Dva Boot Admin
🍰 react admin dashboard ui LANIF-ADMIN --- react 16 + react-router 4 + dva 2 + antd 4 后台管理 脚手架
Stars: ✭ 1,553 (+1286.61%)
Mutual labels:  react-router
React Dashboard
🔥React Dashboard - isomorphic admin dashboard template (React.js, Bootstrap, Node.js, GraphQL, React Router, Babel, Webpack, Browsersync) 🔥
Stars: ✭ 1,268 (+1032.14%)
Mutual labels:  react-router
React Demo Gather
react demo合集,有自己写的,也有在学习过程中觉得很好的demo收集的,持续更新中
Stars: ✭ 97 (-13.39%)
Mutual labels:  react-router
React Koa Login
koa2 + react + react-router(4.0) + redux + webpack + antd
Stars: ✭ 109 (-2.68%)
Mutual labels:  react-router
Mirror
A simple and powerful React framework with minimal API and zero boilerplate.
Stars: ✭ 1,445 (+1190.18%)
Mutual labels:  react-router
Koa Mobx React Starter
A straightforward starter for Node javascript web projects. Using Koa, MobX and ReactJS (with universal / isomorphic server rendering)
Stars: ✭ 102 (-8.93%)
Mutual labels:  react-router

rrc = react router components

Travis

This module contains a number of components that can be used in conjuction with React Router v4. They are a somewhat random assortment of solutions to situations that I have either personally needed a component for or have seen others need a component for.

Installation

npm install --save rrc

UMD

You can also use the UMD version of rrc. This is useful if you are putting together a code snippet.

<script src="https://unpkg.com/[email protected]/umd/rrc.min.js"></script>

Note: The UMD builds are slightly bloated because they have to include React Router's <Route> component and matchPath function. This is because if you use the UMD build of react-router-dom instead of react-router, the ReactRouter global will not exist and rrc's imports will fail. The bloat is less than the extra data required to download the react-router build and this approach requires one less <script> tag.

Components

Read about the various components that are provided in the docs

These include:

<ConfigSwitch> and wrapSwitch

These both provide an alternative approach to React Router's <Switch> component. Intead of passing child elements to the <Switch>, both <ConfigSwitch> and the component returned by the wrapSwitch HOC take an array of route objects via the routes prop.

<ConfigSwitch routes={[
  { path: '/', exact: true, component: Home },
  { path: '/about' component: About }
]}/>

wrapSwitch in particular is useful for animations. It allows you to specify a component that will be used to wrap the matched route, providing better support for nested animations than is available with <Switch>

import { CSSTransitionGroup } from 'react-transition-group'

const CSSSwitch = wrapSwitch(CSSTransitionGroup)

const App = () => (
  <CSSSwitch
    transitionName='slide'
    component='div'
    routes={[
      { path: '/', exact: true, component: Home },
      { path: '/about' component: About }
    ]}
  />
)

<Status>

If you are doing server side rendering, the <Status> component offers an easy way to "render" a status. For example, if you have a "404" component that renders when no routes match, you can include a <Status> element inside of its render method so that your server can send the correct status code with the response.

const NoMatch = () => (
  <div>
    <Status code='404' />
    <h1>404</h1>
    <p>The page you were looking for was not found</p>
  </div>
)

The <Status> component will set a property on the context object that you pass to the <StaticRouter>, so all that you have to do is check the context object's status property.

const context = {}
const markup = renderToString(
  <StaticRouter context={context}>
    <App />
  </StaticRouter>
)

if (context.status === '404') {
  // ...
}

whenActive

The whenActive higher-order component creates <NavLink>-like components. While a <NavLink> can only create <a>s, the component returned by whenActive can render anything that you'd like.

// a button that can navigate
const Button = ({ to, ...rest}, { router }) => (
  <button
    type='button'
    onClick={(e) => {
      e.preventDefault()
      router.history.push(to)
    }}
    {...rest}
  />
)

const ActiveButton = whenActive({ className: 'i-am-active' })(Button)

// usage
const Controls = () => (
  <div>
    <ActiveButton to='/'>Home</ActiveButton>
    <ActiveButton to='/form'>Form</ActiveButton>
  </div>
)

This can also be used in place of the <NavLink> so that you don't have to specify the same "active" props for every location-aware link.

// with NavLink
const Links = () => (
  <div>
    <NavLink to='/one' activeClassName='the-active-class'>One</NavLink>
    <NavLink to='/two' activeClassName='the-active-class'>Two</NavLink>
    <NavLink to='/three' activeClassName='the-active-class'>Three</NavLink>
  </div>
)

// with whenActive
const ActiveLink = whenActive({ className: 'the-active-class' })(Link)
const Links = () => (
  <div>
    <ActiveLink to='/one'>One</ActiveLink>
    <ActiveLink to='/two'>Two</ActiveLink>
    <ActiveLink to='/three'>Three</ActiveLink>
  </div>
)

Related Projects:

  • qhistory - Add query object support to location objects
  • react-router-test-context - Simulate the context.router object. This can be useful if you are doing shallow testing of a component that needs to access React Router's context variables. Typically, though, you should just render your component inside of a <MemoryRouter>.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].