I’m trying to use the @heroicons/react
package. There are bindings to it in rescript-heroicons
but when I try to use them in this little App:
module App = {
type state = Initializing | Done
@react.component
let make = () => {
let (state, setState) = React.useState(() => Initializing)
React.useEffect0(() => {
Js.Global.setTimeout(() => {setState(_ => Done)}, 1_000)->ignore
None
})
switch state {
| Initializing =>
<p style={lineHeight: "0.8rem"}>
<Heroicons.Outline.ChevronDoubleDownIcon className="h-6 w-6 animate-bounce" />
<span> {React.string("Initializing")} </span>
</p>
| Done =>
<p style={lineHeight: "0.8rem"}>
<Heroicons.Solid.CheckCircleIcon className="h-6 w-6" />
<span> {React.string("Done")} </span>
</p>
}
}
}
ReactDOM.querySelector("#app")
->Belt.Option.map(rootElement => {
let root = ReactDOM.Client.createRoot(rootElement)
ReactDOM.Client.Root.render(root, <App />)
})
->ignore
I get errors like:
react-jsx-runtime.development.js:87 Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `Index$App`.
at Index$App (http://localhost:2345/aleph/index.js:24593:23)
printWarning @ react-jsx-runtime.development.js:87
error @ react-jsx-runtime.development.js:61
jsxWithValidation @ react-jsx-runtime.development.js:1244
jsxWithValidationDynamic @ react-jsx-runtime.development.js:1301
Index$App @ index.js:51
renderWithHooks @ react-dom.development.js:16305
mountIndeterminateComponent @ react-dom.development.js:20074
beginWork @ react-dom.development.js:21587
beginWork$1 @ react-dom.development.js:27426
performUnitOfWork @ react-dom.development.js:26557
workLoopSync @ react-dom.development.js:26466
renderRootSync @ react-dom.development.js:26434
performConcurrentWorkOnRoot @ react-dom.development.js:25738
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
react-dom.development.js:28439 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
...
First I thought that it was about rescript-heroicons
being configured for JSX3; but I took the code and embedded it in my project without success.
I don’t see anything strange in the components definitions (but I’m also new to both React and @rescript/react
).
Any ideas?