Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

TypeError: Cannot read property 'history' of undefined #12

Open
ademahendra opened this issue May 16, 2018 · 2 comments
Open

TypeError: Cannot read property 'history' of undefined #12

ademahendra opened this issue May 16, 2018 · 2 comments

Comments

@ademahendra
Copy link

ademahendra commented May 16, 2018

Get error Cannot read property 'history' of undefined on RouterLink

"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-metismenu": "^1.4.0",
"react-metismenu-router-link": "^2.1.0",
"react-router-dom": "^4.2.2",

/**
 * React Starter Kit (https://www.reactstarterkit.com/)
 *
 * Copyright © 2014-present Kriasoft, LLC. All rights reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */
import React, { Component } from 'react';
import MetisMenu from 'react-metismenu';
import RouterLink from 'react-metismenu-router-link';

const content = [
  {
    icon: 'icon-class-name',
    label: 'Label of Item',
    to: 'login',
  },
  {
    icon: 'icon-class-name',
    label: 'Master',
    content: [
      {
        icon: 'icon-class-name',
        label: 'Kandang',
        to: 'about',
      },
    ],
  },
];

class Navigation extends Component {
  render() {
    return (
      <div>
        <MetisMenu content={content} LinkComponent={RouterLink} />
      </div>
    );
  }
}

export default Navigation;

TypeError: Cannot read property 'history' of undefined
    at RouterLink.componentWillMount (D:\react\farm-starter\node_modules\react-metismenu-router-link\lib\RouterLink.js:50:27)
    at processChild (D:\react\farm-starter\node_modules\react-dom\cjs\react-dom-server.node.development.js:2154:16)
    at resolve (D:\react\farm-starter\node_modules\react-dom\cjs\react-dom-server.node.development.js:2048:5)
    at ReactDOMServerRenderer.render (D:\react\farm-starter\node_modules\react-dom\cjs\react-dom-server.node.development.js:2333:22)
    at ReactDOMServerRenderer.read (D:\react\farm-starter\node_modules\react-dom\cjs\react-dom-server.node.development.js:2307:19)
    at Object.renderToString (D:\react\farm-starter\node_modules\react-dom\cjs\react-dom-server.node.development.js:2679:25)
    at _callee$ (D:\react\farm-starter\src\server.js:163:1)
    at tryCatch (D:\react\farm-starter\node_modules\regenerator-runtime\runtime.js:62:40)
    at Generator.invoke [as _invoke] (D:\react\farm-starter\node_modules\regenerator-runtime\runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (D:\react\farm-starter\node_modules\regenerator-runtime\runtime.js:114:21)
    at step (D:\react\farm-starter\build\server.js:2623:221)
    at _next (D:\react\farm-starter\build\server.js:2623:409)
    at <anonymous>
@alpertuna alpertuna added this to the react-metismenu v2 milestone Sep 4, 2018
@alex-brambila
Copy link

I'm getting the same error w React 16. Worked fine w 15. Starting to think it may not be compatible w 16??

@jhillhouse92
Copy link

I'm not sure if this is active or not, but I had the same issue after using react-router 4.4.0-beta+ which removed the context API. I created the pr: #13

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

No branches or pull requests

4 participants