Hi Im trying to add a custom react component based on the tutorial here:
I have the following component and it works fine:
@file:JsModule("react-youtube-lite")
@file:JsNonModule
package ui.bridges
import react.*
@JsName("ReactYouTubeLite")
external val YoutubePlayer: ComponentClass<ReactYouTubeProps>
external interface ReactYouTubeProps : Props {
var url: String
}
But when im trying to add a custom component for react-qr like so:
@file:JsModule("react-qr-code")
@file:JsNonModule
import react.*
@JsName("QRCode")
external val QRCode: ComponentClass<QRCodeProps>
external interface QRCodeProps : Props {
var value: String
}
Im getting the following error:
Warning: React.createElement: 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 `ConnectComponent`.
at ConnectComponent (webpack-internal:///./kotlin/web.js:132824:24)
at div
at div
at div
at ContentComponent (webpack-internal:///./kotlin/web.js:132449:24)
at DashboardComponent (webpack-internal:///./kotlin/web.js:133508:24)
react_devtools_backend.js:2540 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.
Check the render method of `ConnectComponent`.
at createFiberFromTypeAndProps (react-dom.development.js?f6e0:25058)
at createFiberFromElement (react-dom.development.js?f6e0:25086)
at createChild (react-dom.development.js?f6e0:13446)
at reconcileChildrenArray (react-dom.development.js?f6e0:13719)
at reconcileChildFibers (react-dom.development.js?f6e0:14125)
at reconcileChildren (react-dom.development.js?f6e0:16997)
at updateHostComponent (react-dom.development.js?f6e0:17632)
at beginWork (react-dom.development.js?f6e0:19080)
at HTMLUnknownElement.callCallback (react-dom.development.js?f6e0:3945)
at Object.invokeGuardedCallbackDev (react-dom.development.js?f6e0:3994)
This is how i add the youtube video and the qr code. When i comment out the qr part, the video works fine. Something tells we me there's in a difference in how the components are built. But im not sure what. I have almost no knowledge about React so sorry if this a stupid question :)
div {
child(YoutubePlayer) {
attrs {
url = "https://www.youtube.com/watch?v=8o312hBgEmM"
}
}
child(QRCode) {
attrs {
value = "XYZ"
}
}
}