All Projects → jxnblk → rrx

jxnblk / rrx

Licence: MIT license
⚛️ Minimal React router using higher order components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rrx

react-drip-form
☕ HoC based React forms state manager, Support for validation and normalization.
Stars: ✭ 66 (-4.35%)
Mutual labels:  higher-order-component, hoc
Incompose
A inferno utility belt for function components and higher-order components
Stars: ✭ 76 (+10.14%)
Mutual labels:  higher-order-component, hoc
addhoc
Handy little helper to create proper React HOC functions complete with hoisted statics and forwarded refs
Stars: ✭ 40 (-42.03%)
Mutual labels:  higher-order-component, hoc
Recompact
⚛ A set of React higher-order components utilities. Drop-in replacement for recompose.
Stars: ✭ 419 (+507.25%)
Mutual labels:  higher-order-component, hoc
react-app-loader
Production ready library for handling Microfrontends
Stars: ✭ 75 (+8.7%)
Mutual labels:  higher-order-component, hoc
react-animation-frame
A React higher-order component that invokes a callback in a wrapped component via requestAnimationFrame
Stars: ✭ 47 (-31.88%)
Mutual labels:  higher-order-component, hoc
React Bps
🔱 Create breakpoints to your component props
Stars: ✭ 64 (-7.25%)
Mutual labels:  higher-order-component, hoc
react-table-hoc-draggable-columns
ReactTable HOC for draggable columns
Stars: ✭ 27 (-60.87%)
Mutual labels:  higher-order-component, hoc
Hocs
🍱 Higher-Order Components for React
Stars: ✭ 1,784 (+2485.51%)
Mutual labels:  higher-order-component, hoc
Next Nprogress
Next.js HOC to integrate NProgress inside your app
Stars: ✭ 145 (+110.14%)
Mutual labels:  higher-order-component, hoc
Flagged
Feature Flags for React made easy with hooks, HOC and Render Props
Stars: ✭ 97 (+40.58%)
Mutual labels:  higher-order-component, hoc
React Nprogress
⌛️ A React primitive for building slim progress bars.
Stars: ✭ 173 (+150.72%)
Mutual labels:  higher-order-component, hoc
Neoform
✅ React form state management and validation
Stars: ✭ 162 (+134.78%)
Mutual labels:  higher-order-component, hoc
React With Direction
Components to provide and consume RTL or LTR direction in React
Stars: ✭ 176 (+155.07%)
Mutual labels:  higher-order-component, hoc
Klein.php
A fast & flexible router
Stars: ✭ 2,622 (+3700%)
Mutual labels:  routing
Pedalino
Smart wireless MIDI foot controller for guitarists and more.
Stars: ✭ 105 (+52.17%)
Mutual labels:  routing
Vue Cli Plugin Auto Routing
Automatically resolve pages and layouts routing
Stars: ✭ 234 (+239.13%)
Mutual labels:  routing
Looking Glass
Easy to deploy Looking Glass
Stars: ✭ 233 (+237.68%)
Mutual labels:  routing
pinecone
Peer-to-peer overlay routing for the Matrix ecosystem
Stars: ✭ 361 (+423.19%)
Mutual labels:  routing
vue-error-page
[NO LONGER MAINTAINED] Provides a wrapper for router-view that allows you to show error pages without changing the URL.
Stars: ✭ 52 (-24.64%)
Mutual labels:  routing

RRX

Minimal React router using higher order components

npm i -S rrx

Example Usage

// import React from 'react'
// import {
//   createRouter,
//   createView,
//   Link
// } from 'rrx'

const Home = createView((props) => (
  <div>
    <h1>Home</h1>
  </div>
))

const About = createView((props) => (
  <div>
    <h1>About</h1>
  </div>
))

const Post = createView(({
  params
}) => (
  <div>
    <h1>{params.title}</h1>
  </div>
))

class App extends React.Component {
  render () {
    return (
      <div>
        <nav>
          <ul>
            <li><Link href='/'>Home</Link></li>
            <li><Link href='/about'>About</Link></li>
            <li><Link href='/posts/hello'>Hello Post</Link></li>
          </ul>
        </nav>
        <Home pattern='/' />
        <About pattern='/about' />
        <Post
          pattern='/posts/:title'
          foo='bar'
        />
      </div>
    )
  }
}

const Router = createRouter(App)

const props = {
  options: {
    basename: '/rrx'
  }
}

render(<Router {...props} />)

API

createRouter

Higher order component to create a wrapper Router component. This component creates a history object and provides context for both history and location.

Router components provide these objects through context:

  • history - the history object from history
  • location - the location object from history
const App = () => (
  <div>
    <h1>Hello</h1>
  </div>
)

export default createRouter(App)

createView

Creates a view component that accepts a pattern prop for route matching. If the location matches the pattern, the component will render with params and search props. If it does not match, it will not render.

View component props:

Props provided by the HOC:

  • params - object of URL parameters from the given pattern.
  • search - the location.search string
const About = () => (
  <h1>About</h1>
)

export default createView(About)
import About from './About'

const App = () => (
  <div>
    <About pattern='/about' />
  </div>
)

export default createRouter(App)

<Link />

A Link component that uses the history context to transition between routes using the browser History API.

<Link href='/about'>
  About
</Link>

GitHub Made by Jxnblk

MIT License

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].