tleunen / react-number-editor

Custom number editor (text field) react component
MIT License
70 stars 15 forks source link

Using React 0.14 gives a warning: React component classes must extend React.Component. #17

Closed kmcluckie closed 9 years ago

kmcluckie commented 9 years ago

When I use the NumberEditor in a component I get the error/warning: Warning: Component(...): React component classes must extend React.Component.

I don't quite understand why this error is happening, since the package isn't using ES6 classes, which now (since 0.14) require extending React.Component. Maybe it's a dependency? I'm a React beginner, so forgive my ignorance if I'm barking up the wrong tree here.

Anyone used this in React 0.14?

tleunen commented 9 years ago

Is your component using the ES6 class without extending React.Component?

kmcluckie commented 9 years ago

No, it extends from React.Component:

export default class ValuedSlider extends React.Component {
  render() {
    return (
      <NumberEditor min={0} max={1} step={0.01} decimals={2} onValueChange={this.props.onFinalChange} />
    );
  }
}
tleunen commented 9 years ago

I'll try to check that this weekend, but that's weird, are you sure it's because of NumberEditor? Do you have a project or a full file that produce the error so I can test that quickly?

kmcluckie commented 9 years ago

I'll try set up a clean test project to verify this behaviour and get back to you if you like. On 7 Nov 2015 4:12 am, "Tommy" notifications@github.com wrote:

I'll try to check that this weekend, but that's weird, are you sure it's because of NumberEditor? Do you have a project or a full file that produce the error so I can test that quickly?

— Reply to this email directly or view it on GitHub https://github.com/tleunen/react-number-editor/issues/17#issuecomment-154475577 .

kmcluckie commented 9 years ago

OK, so I set up a simple test project to confirm. See the gist at: https://gist.github.com/kmcluckie/457b1a991db379b2719d

Again the error is: Warning: Component(...): React component classes must extend React.Component.

And then, subsequently: Uncaught Error: Invariant Violation: ReactCompositeComponent.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.

It may be something in the config (being a novice to Webpack as well as React!), so I've included that to.

Cheers.

tleunen commented 9 years ago

Thanks a lot @kmcluckie, I can reproduce the error using your code.

tleunen commented 9 years ago

Thanks again @kmcluckie, your gist really helped me. It should be good with the version 4.0 now

kmcluckie commented 9 years ago

Glad to help, thanks for the fix.