1

The code snippet:

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

class Navigation extends Component {
  render(){
    return (

  <Navbar>
    <Navbar.Header>
      <Navbar.Brand>
        Github Searcher
      </Navbar.Brand>
    </Navbar.Header>

    <Nav>
      <NavItem href="#"> Login </NavItem>
    </Nav>
  </Navbar>

    )
  }
}
export default Navigation;

Getting this error message:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of Navigation.

2 Answers 2

3

I could reproduce your error message and there are 2 issues what I have found for you.

First issue:

There is a small typo in the import part. You can correct if you change the first line from Import React, { Component } from 'react' to import React, { Component } from 'react'.

Second issue:

Which is related to the Element type is invalid: expected a string error message.

In react-bootstrap documentation I have found the following for NavbarHeader:

removed, not present in v4

So Navbar.Header needs to be removed and it will work like charm.

I guess you can do something like this:

class Navigation extends Component {
  render() {
    return (
      <Navbar>
        <Navbar.Brand>
          Github Searcher
        </Navbar.Brand>

        <Nav>
          <NavItem href="#"> Login </NavItem>
        </Nav>
      </Navbar>
    )
  }
}

I hope that helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes sorry about that; in copy pasting the code this mistake was made in the actual code 'i' is in lower case. And yes after removing Navbar.Header the error is removed. Thankyou
0

Import of first line should replace by import. components are not included.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.