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:
CustomComponentshould be calledHelloComponentregisterCustomElement.jsshould be namedregisterCustomElement.jsxIt will also fail if any
styleis set on the elm node