0

I am having a lot of trouble trying to implement material-ui's AppBar with Leftbar as there seems to be lots of different variations on component declaration/imported dependencies syntax and components. I can't even find proper documention on http://www.material-ui.com/ about Leftnav in the first place, all they give with Appbar is a static hamburger menu example. My code is as follows:

import React, { Component } from 'react'
import { LeftNav, AppBar} from 'material-ui'
import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import { Router, Route, Navigation, Link, browserHistory } from 'react-router'


export default class Header extends Component  {


  getChildContext() {
    return {muiTheme: getMuiTheme(baseTheme)};
  }

    _toggleNav(){
       this.refs.leftNav.toggle();
     }

        render() {
          const data = this.props.data
          const nav_items = data.globals.nav_items
          //Menu item links
          const menu_items = nav_items.map(( nav_item ) => {
            return (
              <span key={ 'key-' + nav_item.value }>
                <Link to={ '/' + nav_item.value }>{ nav_item.title }</Link>
              </span>
            )
          })
            return (
                <div>
                <LeftNav ref='leftNav'
                docked={false}
                menuItems={ menu_items }  />

                <AppBar   title="App Bar Example" onLeftIconButtonTouchTap={this._toggleNav}
            isInitiallyOpen={true} />
                </div>
            )
        }
    }

    Header.childContextTypes = {
  muiTheme: React.PropTypes.object.isRequired,
};

I am getting to obscure errors which explain me nothing about what am actually doing wrong:

VM15235:27 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `Header

and:

invariant.js:38 Uncaught (in promise) Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Header`.(…)

Is there a way of making this more explicit?

HGB
  • 2,157
  • 8
  • 43
  • 74

1 Answers1

0

There was a change to material-ui that renamed LeftNav to Drawer! It seems like certain docs/examples haven't been updated. So if you use Drawer you will find documentation and it should work! Here is the commit/thread from the change away from LeftNav.

https://github.com/callemall/material-ui/issues/2697

lovelikelando
  • 7,593
  • 6
  • 32
  • 50
  • Thanks for telling me this. I have created a new thread: http://stackoverflow.com/questions/37120713/material-ui-drawer-with-appbar-not-working-with-component-syntax to avoid confusion as I am still having issues in implementing this. – HGB May 09 '16 at 16:21