Fork me on GitHub
#reagent
<
2018-04-28
>
lwhorton21:04:05

how am I supposed to use reagent with a react library that expects children to be a fn? for example, react-dnd:

<DragDropContext onDragEnd={this.onDragEnd}>
        <Droppable droppableId="droppable">
          {(provided, snapshot) => (
            <div
              ref={provided.innerRef}
              style={getListStyle(snapshot.isDraggingOver)}
            >

lwhorton21:04:50

i’m not sure the proper combination of as-element or adapt-react-class, so something like this doesn’t work:

[(r/adapt-react-class DragDropContext) ... 
  [(r/adapt-react-class Droppable) ...
    (fn [pr sn]
      [:div ...])]]
because this is not valid reagent 😕

justinlee21:04:54

@lwhorton you may have to use reactify component

(let [decorator (react-dnd/DragDropContext html5-backend/default)]
      [(reagent/adapt-react-class
        (decorator (reagent/reactify-component router-component)))])))

justinlee21:04:07

where router-component is a reagent component

justinlee21:04:54

but basically you need to run your reagent-side stuff through reactify component or as-element before passing it to react

lwhorton16:04:59

ill take a look, thanks for the help. i wonder though — will ratoms stop working if I’m now returning a fn instead of a [comp

justinlee20:04:37

They’ll work if you run the interior part of the function through as-element or reactify component