redux-history

1.0.2 • Public • Published

Redux History

Connect the history api to redux. Redux History lets you sync redux with rackt history, giving you access to the current location object in your reducers, optionally including URL queries. It's meant to be a dead simple enhancement for redux, it will also work nicely with react-router.

Installation

npm install --save redux-history history

To enable Redux History, use connectHistory() inside your main entry point:

import React from 'react';
import { render } from 'react-dom';
import configureStore from './store/configureStore';
import Root from './containers/Root';
import { connectHistory } from 'redux-history'; 
import { createHistory, useQueries } from 'history';
 
const store = configureStore();
const history = useQueries(createHistory)();
const unconnectHistory = connectHistory(history, store);
 
render(
  <Root store={store} />,
  document.getElementById('root')
);

in your root reducer

import {combineReducers} from 'redux';
import { locationReducer } from 'redux-history';
 
const rootReducer = combineReducers({
  location: locationReducer
});

Usage

 
// examples with:
// with history.push, history.replace
// with custom actions, custom reducers
// with react-router
 

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i redux-history

Weekly Downloads

5

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ezekielchentnik