I have seen several methods of making a facade or wrapping Javascript components in scala.js
, including doing so for react.js Component
s. They seem to vary in the degree they encapsulate or hide the functionality provided by the component itself, I suppose based on their needs (maybe they only need to call one method).
In my case, I need to use a component called react-sticky
and I am first trying to determine how to proceed with making a facade for one of its just two component classes, StickyContainer
, code provided here.
My questions are as follows:
- How do I deal with
static
Javascript methods inscala
? Do I even need to care about this, or can I be agnostic about it? - What is the minimum amount of "facade" I need to make to just include the
component
without anyProps
in anothercomponent
'srender()
? - What is fundamentally different about wrapping or facading a
reactjs
component as opposed to any otherjs
native class?
Finally, which of the following strategies would be most appropriate?
@js.native
trait StickyContainer extends js.Object { ... }
object StickyContainer extends StickyContainer {}
or
case class StickyContainer(offset: js.UndefOr[Double],...) {
def apply() = { React.createElement(ReactUniversal.Image, JSMacro[StickyContainer](this), children: _*)
}