question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using react-handsontable via JSComponent

See original GitHub issue

Hi

Once again thanks for providing us with this fantastic tool!

I’m trying to figure out how to use a 3rd party react component, namely handsontable (https://github.com/handsontable/react-handsontable).

I’ve been following the guide interop guide (https://github.com/japgolly/scalajs-react/blob/master/doc/INTEROP.md) and have the following code for a HotTable component:

object HotTable {
  @JSImport("react-handsontable", "HotTable")
  @js.native
  object RawComponent extends js.Object

  @js.native
  trait Props extends js.Object {
    var data: Seq[Seq[String]] = js.native
  }

  def props(data: Seq[Seq[String]]): Props = {
    val p = (new js.Object).asInstanceOf[Props]
    p.data = data
    p
  }

  val component = JsComponent[Props, Children.None, Null](RawComponent)
}

But upon trying to use it:

<.div(HotTable.component(HotTable.props(Seq(Seq("yeah"))))())

I get a js error:

Uncaught TypeError: Cannot read property ‘ctor__Ljapgolly_scalajs_react_CtorType’ of null at $c_Ldrt_client_components_TerminalContentComponent$Backend.render__Ldrt_client_components_TerminalContentComponent$Props__Ldrt_client_components_TerminalContentComponent$State__Ljapgolly_scalajs_react_vdom_TagOf (Generic.scala:13) at TerminalContentComponent.scala:194 at $c_sjsr_AnonFunction1.apply__O__O (AnonFunctions.scala:15) at ViaReactComponent.scala:256 at $c_sjsr_AnonFunction1.apply__O__O (AnonFunctions.scala:15) at Object.<anonymous> (ViaReactComponent.scala:252) at ReactCompositeComponent.js:796 at measureLifeCyclePerf (ReactCompositeComponent.js:75) at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:795) at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:822)

At this point I’m a little stuck. Any pointers as to where I’m going wrong would be awesome.

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richbirchcommented, Dec 19, 2017

Stop press!

We figured it out after a lot of unpicking. We just needed to change the JSImport line to name the export as the default, ie JSImport.Default:

@JSImport("react-handsontable", JSImport.Default)

Phew. Massive relief. Feels like a whole new world has now opened up to us!

Thanks for the earlier reply Rich

0reactions
richbirchcommented, Dec 28, 2017

Fantastic. Hopefully these issues will help guide others to get it working in future.

Have a great New Year!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Using the HotColumn component - Handsontable
Handsontable is a composite spreadsheet component for apps and websites written in JavaScript and HTML.
Read more >
React Data Grid Column component - Handsontable
Configure your grid's columns, using the props of the HotColumn component. Pass your component as a custom cell editor or a custom cell...
Read more >
React Data Grid Installation - Handsontable
Install Handsontable through your preferred package manager, and control your grid through the HotTable component's props.
Read more >
[react] How could we add a component react to col header?
We are trying to insert a filter component ( react component ) to a column header like image below But handsontable just support...
Read more >
[GH #6466] React How to render a custom component in a cell?
This custom react component basically renders a “typeahead” input box that allows the user to pick a username (that comes from the API)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found