Basic scala-js react facade

(see updates at the bottom: not so much a question now as much as an FYI)


As an exercise, I'm trying to write a partial facade for react in scala-js, a bit like what's found for Phaser [here](https://github.com/sjrd/scalajs-phaser-demo/blob/master/client/src/main/scala/pairs/client/phaser/Phaser.scala)

Note that I’m aware of existing facades such as scalajs-react, scalajs-reactjs, react4s, slinky and definitelyscala’s, but the point here is to better understand how such facades are written.

I managed to get something very dummy like this work:

    MyBindings.ReactDOM.render(
      element = "hello",
      container = org.scalajs.dom.document.getElementById("container"))

But no way- to create even a simple component such ShoppingList (from react’s tutorial ). I tried a number of different combinations, but always end up with a $g.ShoppingList is not a constructor error upon instantiation.

I feel like I’m really missing something conceptually :-/

Any help would be appreciated!

UPDATE 1: minor progress, but new error: see gist

UPDATE 2: I think I got it to work… I had to use React.createElement instead of instantiating the class myself directly… I’m hoping to clean this up and post progress tomorrow

UPDATE 3: this works so far (still very minimal though):

  1. the app
  2. bindings
1 Like