Skip to content

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

@ghost

Description

TypeError: Cannot read property 'history' of undefined
LinkContainer.render
C:/Users/dd/Projects/vv/vv-app/node_modules/react-router-bootstrap/lib/LinkContainer.js:96

Struggling with using react-bootstrap and react-router-bootstrap. I created a basic navbar but no matter what (tried many examples online using a const in a file and a Component itself) but I get that error. Please help

import React, { Component, PropTypes } from 'react';
import { Navbar, Nav, NavItem } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';

class MyNavBar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loggedIn: 1,
    };
  }

  render() {
    return (
      <div>
        <Navbar>
          <Navbar.Header>
            <Navbar.Brand>
              <a href="/">My space</a>
            </Navbar.Brand>
            <Navbar.Toggle />
          </Navbar.Header>
          <Navbar.Collapse>
            <Nav>
              <LinkContainer to="/tips">
                <NavItem>Tips</NavItem>
              </LinkContainer>
              <LinkContainer to="/url-to-link2">
                <NavItem>Item 2</NavItem>
              </LinkContainer>
            </Nav>
          </Navbar.Collapse>
        </Navbar>
        <div className="content">
          {this.props.children}
        </div>
      </div>
    );
  }
}


export default MyNavBar;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions