Search code examples
scala.jsscalajs-react

ScalaJSReact Uncaught referenceError in React.scala


I'm trying out scalajsReact with this hello world example:

object ScalaJSExample {

  def main(args: Array[String]): Unit = {
    val NoArgs =
      ScalaComponent.static(<.div("Hello!"))
    NoArgs().renderIntoDOM(document.body)
}

But I get this runtime error: Uncaught ReferenceError:: React.scala:41

I am using scalajsReact 1.7.5 and React 16.13.1.

Am I doing something wrong or is it a bug??


Solution

  • Turns out I used https://github.com/vmunier/play-scalajs.g8 to seed my project and somehow the bundling was not done properly using this setup. Base on ScalaJsBundler doc, I replaced WebScalaJS with WebScalaJSBundlerPlugin and I worked.