1

I upgraded react to 0.14-rc1 from 0.14 beta3 , now i am seeing warnings

Warning: $c_Hello$Component(...): React component classes must extend React.Component.

but my component extending React.Component

object Hello {
  @ScalaJSDefined
  class Component extends ReactComponent[Unit, Unit] {
    def render() = React.createElement("div",null,"hello")
  }
}

no warnings in 0.14 beta3.

i think logic here is not correct ? : https://github.com/facebook/react/blob/b01af40ae64823fb963a8fa6ced3c42ae09fad55/src/renderers/shared/reconciler/ReactCompositeComponent.js#L170

in debug mode inst instanceof Component is true

2
  • The logic there is correct - warning warns when the first argument is false. So inverting the instanceof gives us what we want. What is ReactComponent in your code? Is it React.Component? Or is this something going differently in the transpilation from Scala to JS?l Commented Sep 10, 2015 at 20:54
  • its React.Component from reactjs ,i am just using alias for convenience in my code base . Commented Sep 10, 2015 at 20:55

1 Answer 1

3

Looks like this is a scala-js bug where the .isReactClass flag doesn't get copied over. I've filed an issue there:Static class properties should be inherited

It looks like your code might also work if you change your sbt settings to use

scalaJSOutputMode := org.scalajs.core.tools.javascript.OutputMode.ECMAScript6

and then it will use native ES6 classes. But the blog post in which it was introduced suggests it's not ready for production use.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.