I would like to make use of a component that is defined afterwards. For example:
// TreeItem uses TreeList
module TreeItem = {
@react.component
let make = (~item: item) => {
<>
<li id=item.id>{React.string(item.name)}</li>
<TreeList items=item.items /> /* this throws an error */
</>
}
}
// and TreeList uses TreeItem
module TreeList = {
@react.component
let make = (~items: array<item>) => {
<ul>
{items
->Belt.Array.map(item => <TreeItem item=item />)
->React.array}
</ul>
}
}
however the previous code throws the following error:
The module or file TreeList can't be found.
How can I use a component even if it has been defined afterward?