purescript-contrib/purescript-react

New API is confusing (to me, anyway)

paf31 opened this issue · 4 comments

paf31 commented

I can't figure out why this isn't working:

ui = D.div' [ createLeafElement cls {} ]

where

cls :: ReactClass {}

I get

  133    ui = D.div' [ createLeafElement (explore together) {} ]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  No type class instance was found for
  
    Prim.Row.Union t0
                   t2
                   ()

Your source and error don't appear to align. Your error says your component is explore together, not cls. I'm assuming you probably have a forall on props. createElement has constraints to handle the reserved props key and ref, which can be confusing. If you have a forall, you'll have to instantiate it to something before passing it to createElement. The old behavior is available as unsafeCreateElement. This is worth documenting.

paf31 commented

Ok, I see, thanks. Yeah, definitely sounds like it's worth documenting.

paf31 commented

For some reason, I can't use unsafeCreateLeafElement, I get

  Cannot import value unsafeCreateLeafElement from module React
  It either does not exist or the module does not export it.

but it clearly exists and is exported so I don't know what's going on.

paf31 commented

Ignore that, sorry, it works when I use the latest tag.