ScalaJSReact Uncaught referenceError in React.scala

58 views Asked by At

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??

1

There are 1 answers

0
stackoverflowed On BEST ANSWER

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.