acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 216 forks source link

Add tags for 1.0.0-beta8 version #249

Closed anton-rodin closed 8 years ago

anton-rodin commented 8 years ago

Hi! When I'm trying to install 1.0.0-beta8 version via npm, I actually receive 1.0.0-beta6 version which don't support react-router: 2.0.0. @Scarysize Could you please update tags?

Thanks!

Scarysize commented 8 years ago

Hm, are you installing it with a specific version or just the latest? I´m getting beta8 if I do npm install redux-router

anton-rodin commented 8 years ago

I install 1.0.0-beta8 version. I'm using react-router: "2.0.1" Actually in node_modules folder in redux-router package.json I see 1.0.0-beta8 version, but if compare reduxReactRouter.js in github repo and in node_modules folder I have completely different versions

Github https://github.com/acdlite/redux-router/blob/master/src/reduxReactRouter.js

'use strict';

exports.__esModule = true;
exports['default'] = reduxReactRouter;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _redux = require('redux');

var _reactRouter = require('react-router');

var _historyMiddleware = require('./historyMiddleware');

var _historyMiddleware2 = _interopRequireDefault(_historyMiddleware);

var _constants = require('./constants');

function reduxReactRouter(_ref) {
  var routes = _ref.routes;
  var createHistory = _ref.createHistory;
  var parseQueryString = _ref.parseQueryString;
  var stringifyQuery = _ref.stringifyQuery;
  var routerStateSelector = _ref.routerStateSelector;

  return function (createStore) {
    return function (reducer, initialState) {

      var baseCreateHistory = undefined;
      if (typeof createHistory === 'function') {
        baseCreateHistory = createHistory;
      } else if (createHistory) {
        baseCreateHistory = function () {
          return createHistory;
        };
      }

      var history = _reactRouter.useRoutes(baseCreateHistory)({
        routes: routes,
        parseQueryString: parseQueryString,
        stringifyQuery: stringifyQuery
      });

      ['pushState', 'push', 'replaceState', 'replace', 'setState', 'go', 'goBack', 'goForward', 'listen', 'createLocation', 'match'].forEach(function (funcName) {
        if (!history.hasOwnProperty(funcName) && typeof history[funcName] === 'function') {
          throw new Error('History API does not support function: ' + funcName);
        }
      });

      var store = _redux.applyMiddleware(_historyMiddleware2['default'](history))(createStore)(reducer, initialState);

      store.history = history;
      store[_constants.ROUTER_STATE_SELECTOR] = routerStateSelector;

      return store;
    };
  };
}

module.exports = exports['default'];

This is what throw errors in console:

      var history = _reactRouter.useRoutes(baseCreateHistory)({
        routes: routes,
        parseQueryString: parseQueryString,
        stringifyQuery: stringifyQuery
      });

reactRouter.useRoutes is deprecated.

if I install last github commit version, everything works fine.

Scarysize commented 8 years ago

The github isn´t always up-to-date with the published npm package. The react-router v2 change was merged a while ago into the repo, but I just published it yesterday to npm with the beta tag. You can install it via npm install redux-router@beta.