Skip to content

ezekielchentnik/redux-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

connect history to redux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published