react-mdl-extra icon indicating copy to clipboard operation
react-mdl-extra copied to clipboard

Importing any extra component causes "uhandled error event"

Open mewa opened this issue 9 years ago • 8 comments

Importing any component import { AutoComplete } from 'react-mdl-extra'; from react-mdl-extra causes

events.js:141
      throw er; // Unhandled 'error' event

mewa avatar Jan 31 '17 02:01 mewa

What version are you using? Which bundler (webpack, rollup, ...)?

For me it works without problems. This is an example AutoComplete component for redux-forms

import React, { PropTypes } from 'react'

import { AutoComplete } from 'react-mdl-extra'

const renderAutoCompleteField = props => {
  const { children, input, meta: { touched, error }, ...other } = props
  const extra = {
    error: touched && error,
  }
  return (
    <AutoComplete floatingLabel {...input} {...other} {...extra}>
      {children}
    </AutoComplete>
  )
}

renderAutoCompleteField.propTypes = {
  dataIndex: PropTypes.string.isRequired,
  input: PropTypes.object.isRequired,
  items: PropTypes.array.isRequired,
  label: PropTypes.string.isRequired,
  meta: PropTypes.object.isRequired,
  valueIndex: PropTypes.string.isRequired,
}

export default renderAutoCompleteField

HriBB avatar Feb 06 '17 13:02 HriBB

Hi, I have the same problem. Here are the possibly relevant npm packages I am using:

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

If trying to bundle the source using Browserify, I get the following error: Unhandled 'error' event SyntaxError: Unexpected token

ikovic avatar Feb 09 '17 08:02 ikovic

Hmm ... can you please provide some more info? It's hard to tell what's going on ...

HriBB avatar Feb 09 '17 08:02 HriBB

I'm having trouble getting a more verbose error log from Gulp. This is my build task for JS files:

gulp.task('js', function () {
  browserify(paths.JS_MAIN)
    .transform(babelify, {presets: ["es2015", "react"]})
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(gulp.dest(paths.JS_BUILD));
});

The error happens if I import any of the MDL extra components. I'd like to help you with more info, but this is as far as it gets. If I manage to get a better error report, I'll post it.

ikovic avatar Feb 09 '17 08:02 ikovic

I don't use browserify, so I really have no idea what could the problem be. Maybe try to catch some errors in the build process? @mewa are you using browserify as well?

Could be that I'm bundling the package incorrectly.

HriBB avatar Feb 09 '17 10:02 HriBB

Hi, my colleague helped me with getting a more detailed error message from browserify, this is what we came up with:

ParseError
annotated: "/Users/engine/Projects/browserify-test/node_modules/react-mdl-extra/lib/Menu/Menu.css:1.mdl-portalmenu ParseError: Unexpected token"
column: 1
line: 1
message: "Unexpected token"

I don't know if that is going to help you, it's the best we could do for now.

ikovic avatar Feb 09 '17 18:02 ikovic

Thanks, will check it out soon. You are welcome to make a PR 😉

HriBB avatar Feb 09 '17 20:02 HriBB

@HriBB Yes, I'm using browserify as well - sorry for not saying it upfront etc., but I'm swarmed with other stuff at the moment ;)

mewa avatar Feb 13 '17 21:02 mewa