react-hash-routing

1.0.0 • Public • Published

react-hash-router

A hash router for React

Install in your project

npm i react-hash-routing

Quick start

import React from 'react';
import HashRouter, {Route} from 'react-hash-routing';
 
export default class Sample extends React.Component {
  ...
  onLocationChanged (childKey, params, cb) {
      switch (childKey) {
        case 'home':
          cb()
          break
        case 'contacts':
          cb()
          break
        case 'customPage':
          cb()
          break
        default:
          cb()
          break
      }
    },
  render() {
    return (
      <HashRouter onLocationChanged={this.onLocationChanged}>
       <Route key='home' hash='#/'>Home</Route>
       <Route key='contacts' hash='#/contacts'>Contacts</Route>
       <Route key='contacts' hash='#/contacts'>
           <YourCustomComponent />
       </Route>
      </HashRouter>
    )
  }
}

Build sources

npm i

Develop mode

npm run develop

Package Sidebar

Install

npm i react-hash-routing

Weekly Downloads

2

Version

1.0.0

License

ISC

Last publish

Collaborators

  • antoniogiordano