1.0.2 • Published 8 years ago

redux-history v1.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

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

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago