警告:使用 ScalaJS 时,React 组件 类 必须扩展 React.Component
Warning: React component classes must extend React.Component when using ScalaJS
我从 0.14 beta3 升级到 0.14-rc1,现在我看到了警告
Warning: $c_Hello$Component(...): React component classes must extend
React.Component.
但我的组件扩展 React.Component
object Hello {
@ScalaJSDefined
class Component extends ReactComponent[Unit, Unit] {
def render() = React.createElement("div",null,"hello")
}
}
0.14 beta3 中没有警告。
在调试模式下 inst instanceof Component
为真
看起来这是一个 scala-js 错误,其中 .isReactClass 标志没有被复制。我在那里提交了一个问题:Static class properties should be inherited
如果您将 sbt 设置更改为使用,您的代码似乎也可以工作
scalaJSOutputMode := org.scalajs.core.tools.javascript.OutputMode.ECMAScript6
然后它将使用原生 ES6 类。但是 the blog post in which it was introduced 表明它还没有准备好用于生产。
我从 0.14 beta3 升级到 0.14-rc1,现在我看到了警告
Warning: $c_Hello$Component(...): React component classes must extend React.Component.
但我的组件扩展 React.Component
object Hello {
@ScalaJSDefined
class Component extends ReactComponent[Unit, Unit] {
def render() = React.createElement("div",null,"hello")
}
}
0.14 beta3 中没有警告。
在调试模式下 inst instanceof Component
为真
看起来这是一个 scala-js 错误,其中 .isReactClass 标志没有被复制。我在那里提交了一个问题:Static class properties should be inherited
如果您将 sbt 设置更改为使用,您的代码似乎也可以工作
scalaJSOutputMode := org.scalajs.core.tools.javascript.OutputMode.ECMAScript6
然后它将使用原生 ES6 类。但是 the blog post in which it was introduced 表明它还没有准备好用于生产。