reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
2020-10-13T02:55:27.061200Z

I’m trying to translate this piece of react-bootstrap code

<Dropdown as={NavItem}>
  <Dropdown.Toggle as={NavLink}>Click to see more…</Dropdown.Toggle>
  <Dropdown.Menu>
    &lt;Dropdown.Item&gt;Hello there!&lt;/Dropdown.Item&gt;
  &lt;/Dropdown.Menu&gt;
&lt;/Dropdown&gt;;
from https://react-bootstrap.netlify.app/components/navs/#using-dropdowns

2020-10-13T02:56:01.061900Z

My question is how can I build the {NavItem} part?

p-himik 2020-10-13T08:09:19.062200Z

reagent.core/reactify-component.

2020-10-13T14:47:11.062800Z

2020-10-13T14:47:21.063200Z

thanks @p-himik I didn’t work that way but it’s working now, I just passed the element

victorb 2020-10-13T15:10:26.063400Z

Don't think you need the :&gt; here, just [Dropdown] will do.

2020-10-13T15:46:42.063700Z

@victorbjelkholm429 why do you say it is not needed? Dropdown, Nav.Item, etc are react classes from React-Bootstrap library and they need to “read” by reagent . FYI: I tried removing the :&gt; and it didn’t work.

victorb 2020-10-13T16:00:30.063900Z

sorry, was mixing :&gt; with :&lt;&gt; for fragments, never mind my comment 🙂

rberger 2020-10-13T22:18:29.064100Z

@wvelezva Are you using something like react-bootstrap? It has a NavDropdown component https://react-bootstrap.github.io/components/navs/#nav-dropdown-props

2020-10-13T22:24:28.064300Z

@rberger, yes, I’m using react-bootstrap, my problem with NavDropdown was that I needed an Image as the trigger to open the dropdown, and the only way was using the title prop but I don’t know how to write that in clojurescript

2020-10-13T22:25:13.064500Z

but the code I posted earlier works the same, and the Dropdown.Toggle can receive a child image, icon in this case

rberger 2020-10-13T22:38:32.064700Z

The react-bootstrap docs say title is a node as “The content of the non-toggle Button.” which is kind of vague but I presume it means a DOM node. Potentially you could create the icon and use :ref attribute to get the DOM node of the icon and pass that in. But that is kind of funky. Did find this react-bootstrap example https://stackoverflow.com/a/45941992 You could probably use any react-icon component instead of Glyphicon. One of the comments shows how to use react-icons, which is what we use.

p-himik 2020-10-13T08:09:19.062200Z

reagent.core/reactify-component.

2020-10-13T14:47:11.062800Z

2020-10-13T14:47:21.063200Z

thanks @p-himik I didn’t work that way but it’s working now, I just passed the element

victorb 2020-10-13T15:10:26.063400Z

Don't think you need the :&gt; here, just [Dropdown] will do.

2020-10-13T15:46:42.063700Z

@victorbjelkholm429 why do you say it is not needed? Dropdown, Nav.Item, etc are react classes from React-Bootstrap library and they need to “read” by reagent . FYI: I tried removing the :&gt; and it didn’t work.

victorb 2020-10-13T16:00:30.063900Z

sorry, was mixing :&gt; with :&lt;&gt; for fragments, never mind my comment 🙂

rberger 2020-10-13T22:18:29.064100Z

@wvelezva Are you using something like react-bootstrap? It has a NavDropdown component https://react-bootstrap.github.io/components/navs/#nav-dropdown-props

2020-10-13T22:24:28.064300Z

@rberger, yes, I’m using react-bootstrap, my problem with NavDropdown was that I needed an Image as the trigger to open the dropdown, and the only way was using the title prop but I don’t know how to write that in clojurescript

2020-10-13T22:25:13.064500Z

but the code I posted earlier works the same, and the Dropdown.Toggle can receive a child image, icon in this case

rberger 2020-10-13T22:38:32.064700Z

The react-bootstrap docs say title is a node as “The content of the non-toggle Button.” which is kind of vague but I presume it means a DOM node. Potentially you could create the icon and use :ref attribute to get the DOM node of the icon and pass that in. But that is kind of funky. Did find this react-bootstrap example https://stackoverflow.com/a/45941992 You could probably use any react-icon component instead of Glyphicon. One of the comments shows how to use react-icons, which is what we use.