Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 866 Bytes

README.md

File metadata and controls

46 lines (34 loc) · 866 Bytes

alt-router

Setup

import AltRouter from 'alt-router'
import React from 'react'
import createBrowserHistory from 'history/lib/createBrowserHistory'

// your alt instance
import alt from '../alt'

const routes = (
  <Route path="/" component={App}>
    <Route path="about" component={About} />
    <Route path="inbox" component={Inbox} />
  </Route>
)

React.render((
  <AltRouter flux={alt} history={createBrowserHistory()} routes={routes} />
), document.getElementById('root'))

Changing routes

import alt from '../alt'

const changeRoute = () => {
  alt.router.pushState(null, '/home')
}

Bootstrap routes

For when you want to reload a user's entire application state including which route they were in

const bootstrapState = {
  state: null,
  pathname: '/notifications',
}

alt.bootstrap({ AltHistoryStore: bootstrapState })