First you will need document-register-element
yarn add document-register-element
Create a JS function to register React Components as Custom elements. See registerCustomElement.js
below
e.g. HelloComponentCustomElement.jsx
import registerCustomElement from "registerCustomElement"
function HelloComponent(props) {
return (
<div>Hello</div>
)
}
registerCustomElement(CustomComponent, "hello-component")
e.g. in App.js
// Custom Elements
import "app/widgets/HelloComponentCustomElement.jsx"
e.g. in View.Elm
node "hello-component" [ attribute "some-prop" encodedJsonValue ] []
Thanks, I needed to fix two things:
CustomComponent
should be calledHelloComponent
registerCustomElement.js
should be namedregisterCustomElement.jsx
It will also fail if any
style
is set on the elm node