[ReasonReact][bs-rsuite-ui-react] Passing component as prop

reasonreact

#1

Hi
I’m new to ReasonML (but got experience with React.js).
Started working on new project and wanted to use ReasonReact and bs-rsuite-ui-react.
In my code I wanted to pass Icon component to RsuiteUi.Nav.Item. According to ReasonReact documentation this should be trivial (normal function), but it isn’t.
This binding expects something like this:

~?icon: option(
    RsuiteUi.Icon.Props.t => React.element
),

I tried multiple things like:
<RsuiteUi.Nav.Item icon={() => <RsuiteUi.Icon icon="dashboard" />}> and many more, but it doesn’t work. Tried with named arguments, named with type but no success. Any body could help me with this?


#2

Can you try: <RsuiteUi.Nav.Item icon=RsuiteUi.Icon.make />


#3

@yawaramin
Tried

<RsuiteUi.Nav.Item icon=RsuiteUi.Icon.make(~icon="dashboard")>

and got this error:

Error: The function applied to this argument has type
         {. "children": option(React.element), "className": option(string),
           "classPrefix": option(string), "fixedWidth": option(bool),
           "flip": option([ `horizontal | `vertical ]),
           "icon": option(string), "inverse": option(bool),
           "pulse": option(bool), "rotate": option(int),
           "size": option([ `lg ]), "spin": option(bool),
           "style": option(ReactDOMRe.Style.t),
           "svgStyle": option(ReactDOMRe.Style.t)} =>
         React.element
This argument cannot be applied with label ~icon

#4

What happens when you try the one I suggested?


#5

@yawaramin This error

Error: This expression has type
         React.componentLike({. "children": option(React.element),
                               "className": option(string),
                               "classPrefix": option(string),
                               "fixedWidth": option(bool),
                               "flip": option([ `horizontal | `vertical ]),
                               "icon": option(string),
                               "inverse": option(bool),
                               "pulse": option(bool), "rotate": option(int),
                               "size": option([ `lg ]), "spin": option(bool),
                               "style": option(ReactDOMRe.Style.t),
                               "svgStyle": option(ReactDOMRe.Style.t)},
                              React.element)
           =
           {. "children": option(React.element), "className": option(string),
             "classPrefix": option(string), "fixedWidth": option(bool),
             "flip": option([ `horizontal | `vertical ]),
             "icon": option(string), "inverse": option(bool),
             "pulse": option(bool), "rotate": option(int),
             "size": option([ `lg ]), "spin": option(bool),
             "style": option(ReactDOMRe.Style.t),
             "svgStyle": option(ReactDOMRe.Style.t)} =>
           React.element
       but an expression was expected of type
         RsuiteUi.Icon.Props.t => React.element
       Type
         {. "children": option(React.element), "className": option(string),
           "classPrefix": option(string), "fixedWidth": option(bool),
           "flip": option([ `horizontal | `vertical ]),
           "icon": option(string), "inverse": option(bool),
           "pulse": option(bool), "rotate": option(int),
           "size": option([ `lg ]), "spin": option(bool),
           "style": option(ReactDOMRe.Style.t),
           "svgStyle": option(ReactDOMRe.Style.t)}
       is not compatible with type
         RsuiteUi.Icon.Props.t = RsuiteUi.Icon.Props.t 

Maybe implementation of this component will help you: