Search code examples
scala.jsbinding.scala

Integrating React Component in a Binding.scala application


I would like to integrate react-table which is a React Component (can be seen in action here) in a Binding.scala application. I am however fairly new to both React and Binding.scala, and as such was wondering if there were any guides out there on how to proceed? Or if anyone has already done something similar?

PS: note that the gitter channel for Binding.scala specifically asks for general questions to be asked on here


Solution

  • I recently created some adapters for React and Binding.scala Interoperability. See https://github.com/Atry/ReactToBindingHtml.scala

    The usage is basically as simple as import com.yang_bo.ReactToBindingHtml.Implicits._

    import com.yang_bo.ReactToBindingHtml.Implicits._
    
    val reactElement: ReactElement = ???
    @html val realDom: Binding[Node] = {
      // real DOM fieldset element
      <fieldset>
        <legend>
          I am an `@html` literal that contains a React component
        </legend>
        { reactElement }
      </fieldset>
    }