Skip to content
/ router Public

Connect react-router to alt so you can have routes in flux

Notifications You must be signed in to change notification settings

altjs/router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 })

About

Connect react-router to alt so you can have routes in flux

Resources

Stars

Watchers

Forks

Packages

No packages published