I am attempting to use ReactJS components react-transition-group
for creating bindings for it - http://reactcommunity.org/react-transition-group/transition.
How to do I model the children
attribute where it either accepts either an React.element
or a function which returns a React.component
-http://reactcommunity.org/react-transition-group/transition#Transition-prop-children
I tried the following approach but bucklescript complains with the following error message
bs.obj label children does not support [@bs.unwrap] arguments
module Transition = {
[@bs.module "react-transition-group/Transition"] [@react.component]
external make:
(
~_in: bool,
~timeout: int,
~children: [@bs.unwrap][ | `Func(string => React.element) | `Elem(React.element)]
) =>
React.element =
"default";
};
Alternately, I imported the Transition
component via the following mechanism. However, I feel the approach above would be much better if I can make it work. Any pointers?
module TransitionElem = {
[@bs.module "react-transition-group/Transition"] [@react.component]
external make:
(
~_in: bool,
~timeout: int,
~children: React.element
) =>
React.element =
"default";
};
module TransitionFunc = {
[@bs.module "react-transition-group/Transition"] [@react.component]
external make:
(~_in: bool, ~timeout: int, ~children: string => React.element) =>
React.element =
"default";
};