Skip to content

React-MD UI toolkit doesn't work with Next.js #196

Closed

Description

@frol

I am trying to use different UI toolkits and so far I haven't succeeded with any. Material-UI issue is already reported as #119, but React-MD raises another error, so I thought it should be reported separately.

Here is the pages/index.js:

import React from 'react'
import Head from 'next/head'
import { RaisedButton } from 'react-md/lib/Buttons'

export default class App extends React.Component {
  handleClick() {
    console.log("clicked!")
  }
  render() {
    return <div>
      <Head>
        <link rel="stylesheet" href="https://npmcdn.com/react-md/dist/react-md.css" />
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
      </Head>
      <div>
        <RaisedButton label="Hello, World!" onClick={this.handleClick} />
      </div>
    </div>
  }
}

Here are the npm dependencies:

$ npm install --save next react-md react-addons-transition-group react-addons-pure-render-mixin react-addons-css-transition-group

On page load I see the following warnings:

Warning: getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.
Warning: getInitialState was defined on ReactTransitionGroup, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?

The first warning points to this line: https://github.com/mlaursen/react-md/blob/bec6b087eb0a6af38f0a0613d25d8a17f6c7b0a6/src/js/Inks/injectInk.js#L243. However, I couldn't locate the real source of the second warning.

And here is what I get on a button click:

Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded
Uncaught TypeError: Cannot read property 'componentWillLeave' of undefined

The line of code where the error occurs is inside React: https://github.com/facebook/react/blob/c78464f8ea9a5b00ec80252d20a71a1482210e57/src/addons/transitions/ReactTransitionGroup.js#L194

I do get clicked! logged, but the "bubble" animation doesn't work.

It seems that something magical happens and it feels like there are two Reacts are loaded somehow, so the ref keys are not registered.

Activity

  1. frol commented on Nov 5, 2016

    @frol
    ContributorAuthor

    I am closing this in favor of a more specific #204 bug report.

  2. locked as resolved and limited conversation to collaborators on May 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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