Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.js:34416 Uncaught TypeError: createHistory is not a function #280

Open
stefensuhat opened this issue Dec 1, 2016 · 8 comments
Open

Comments

@stefensuhat
Copy link

stefensuhat commented Dec 1, 2016

Version ^2.1.2

react-router version: "react-router": "^3.0.0",
history version: "history": "^4.3.0",

Steps to reproduce

    import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose } from 'redux';
import { Router, browserHistory } from 'react-router';
import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router';
import reduxThunk from 'redux-thunk';
import { createHistory } from 'history';

import rootReducer from './core/rootReducer';
import routes from './core/routes';

import * as axios from './utils/axios.js';

import { AUTH_USER } from './authentication/types';

const store = compose(applyMiddleware(reduxThunk),
    reduxReactRouter({ routes, createHistory })
)(createStore)(rootReducer);

const token = localStorage.getItem('token');

if (token) {
    store.dispatch({ type: AUTH_USER });
}

ReactDOM.render(
    <Provider store={store}>
        <ReduxRouter>
            <Router>
                {routes}
            </Router>
        </ReduxRouter>
    </Provider>
    , document.querySelector('.main')
);

Expected Behavior

Work properly.

Actual Behavior

It return an error index.js:34416 Uncaught TypeError: createHistory is not a function(…)

@stefensuhat
Copy link
Author

stefensuhat commented Dec 1, 2016

After changing import { createHistory } from 'history'; to import createHistory from 'history/createBrowserHistory';

The error become Uncaught TypeError: history.getCurrentLocation is not a function

Solution?

@andfk
Copy link

andfk commented Dec 4, 2016

Did you solved this issue finally?

Thanks

@stefensuhat
Copy link
Author

@andfk no. I've changed my plugin to react-router-redux instead. maybe the problem lies within the history package i used is unsupported

@andfk
Copy link

andfk commented Dec 5, 2016

@ssuhat great. I ended doing the same. Thanks for reply

@Darmikon
Copy link

Why was it closed? It still doesn't work. Moreover react-router-redux is not a solution. It doesn't have params in store. I propose to reopen this bug.

@stefensuhat
Copy link
Author

@Darmikon ok i reopen it.

@stefensuhat stefensuhat reopened this Jan 26, 2017
@grundiss
Copy link

grundiss commented Feb 5, 2017

Any news here? :(

aij added a commit to aij/redux-router that referenced this issue Feb 22, 2017
Enables npm to produce a UNMET PEER DEPENDENCY warning
when incompatible peer dependencies are installed,
such as in issue acdlite#280.
@ndeamador
Copy link

ndeamador commented Nov 21, 2020

I had the same error when using useRouterMatch, which apparently can't be used in the same component that defines the routing.

I don't know if it would be the same here, but in my case moving the tags from App.js to ReactDom.render in index.js solved the issue.

import {BrowserRouter as Router} from 'react-router-dom'
ReactDOM.render(
  <Router>
    <App />
  </Router>,
  document.getElementById('root'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants