japgolly / scalajs-react

Facebook's React on Scala.JS
https://japgolly.github.io/scalajs-react/
Apache License 2.0
1.64k stars 231 forks source link

ReactComponentB not available #14

Closed bblfish closed 9 years ago

bblfish commented 9 years ago

I am trying to port the the URI library testing code to scalajs-react and I get the following error with the most simple hello world I am trying to put together to get going.

It says in red at the bottom:

GET file:///home/golly/projects/scalajs-react/core/src/main/scala/japgolly/scalajs/react/ReactComponentB.scala net::ERR_FILE_NOT_FOUND

which seems like it is a problem even if I would not be surprised that there is a problem with my setup somehow too...

screen shot 2014-08-05 at 17 59 27

dispalt commented 9 years ago

That is just for the sourcemap. There is something weird with sourcemaps for scala.js that I haven't figured out yet, I know @lihaoyi libraries have the same issue. you may want to try relativeSourceMaps in your build configuration.

bblfish commented 9 years ago

thanks that fixes that issue. I am now just left with

Uncaught TypeError: Cannot read property 'createClass' of undefined ReactComponentB.scala:109
ScalaJS.c.Ljapgolly_scalajs_react_ReactComponentB$B2$B3$B4.create__O ReactComponentB.scala:109
ScalaJS.c.Lakka_http_test_ScalaReactSpeedTest$.example1__Lorg_scalajs_dom_Node__Ljapgolly_scalajs_react_ComponentScopeM ScalaReactSpeedTest.scala:24
ScalaJS.c.Lakka_http_test_ScalaReactSpeedTest$.main__V ScalaReactSpeedTest.scala:17
ScalaJS.c.Lakka_http_test_ScalaReactSpeedTest$.$$js$exported$meth$main__O ScalaReactSpeedTest.scala:15
ScalaJS.c.Lakka_http_test_ScalaReactSpeedTest$.main ScalaReactSpeedTest.scala:15
(anonymous function)

which I suppose means that there is some library I am not importing....

dispalt commented 9 years ago

You have to include the react-with-addons.js on your page before your app.

bblfish commented 9 years ago

Ah that does it yes. I was going by your examples that don't include it and work nicely. I thought all of those dependencies would be placed in the ./target/scala-2.11/http-model-uri-browsertest-jsdeps.js file that I have included.

dispalt commented 9 years ago

The example uses jsDependencies which includes the react webjar, so it's a bit more convoluted. Glad it worked!

bblfish commented 9 years ago

Ok, I just simplified the jsDependencies code in the build file as shown in the commit b7030b5 and it worked without the js import in the html. It looks like I had it all there but just was being a bit too clever by re-using your useReact function.

japgolly commented 9 years ago

Glad it all worked out @bblfish, and thanks @ddispaltro for being so helpful! :wink: :beers: