Next.js: Error with onTouchTap and material-ui

Created on 29 Jan 2017  路  14Comments  路  Source: vercel/next.js

A previous issue was closed dealing with how to initialize the injectTapEventPlugin function. However, after having solved that according to the issue, I'm still getting errors using a dropdown menu in material-ui.

Code:

const Header = (props) => {
  const { position, referralLink } = props;
  return (
    <AppBar
      className="flex-container-left appbar"
      title={(
        <a href="/" className="logo-title">
          <img src="/static/images/image.svg" height="50" alt="company logo"/>
        </a>
      )}
      iconElementLeft={<span />}
      iconElementRight={(
        <IconMenu
          className="navigation-close"
          iconButtonElement={<IconButton><NavigationMenu /></IconButton>}
          targetOrigin={{ horizontal: 'right', vertical: 'top' }}
          anchorOrigin={{ horizontal: 'right', vertical: 'top' }}
        >
          <MenuItem
            primaryText="Home"
            onTouchTap={() => console.log('/home')}
          />
          <MenuItem
            primaryText="Status & Leaderboard"
            onTouchTap={() => console.log('/status')}
          />
        </IconMenu>
      )}
    />
  );
}

Error:
screen shot 2017-01-29 at 9 28 40 am

screen shot 2017-01-29 at 9 35 11 am

Most helpful comment

All 14 comments

@tgoldenberg is it possible to have a sample repo? It's quite hard to figure it out like this.

@arunoda sure, I'll try to get one ready.

I would like to just share my experience with React-MD, which is an alternative implementation of Google Material UI for React. React-MD just works with Next.js like a charm for me.

@frol Are you using a custom webpack config to get it working?

@tgoldenberg I'll have a look at this too.

May be this issue is related too: https://github.com/zeit/next.js/issues/882#issuecomment-275940934

@ugiacoman No, I have just installed it (npm install --save react-md), import it (import ... from 'react-md/...'), and added compiled CSS files and fonts using <Head>. That is it.

@frol, I'll checkout react-md, but I think the issue still remains. A lot of people use material-ui, and migrating isn't always that easy.

@frol could you please elaborate on how you compile and add compiled files to Head? (I'm new to next.js)

Hey, just update to next 2.0.0-beta.20 and adapt your jsx styling. For testing I commented out

  • import LandingPageContent from '../components/splash/LandingPageContent.js';

Your button was working then.

/Jan

@alexedev @tgoldenberg I have just PRed the example of using React-MD with Next.js: #940

@frol great, thank you

Still having this problem with 2.0.0-beta.24

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DvirSh picture DvirSh  路  3Comments

irrigator picture irrigator  路  3Comments

pie6k picture pie6k  路  3Comments

knipferrc picture knipferrc  路  3Comments

sospedra picture sospedra  路  3Comments