Register external components for Macaron
This package is used to register external components for Macaron in external component render scripts.
Install
$ npm install -g @macaron-app/register-external-components
Use
import { registerExternalComponents } from "@macaron-app/register-external-components";
registerExternalComponents([
{
importPath: "./path/to/CustomButton",
importName: "CustomButton",
props: {
children: {
type: "string",
},
type: {
values: ["primary", "secondary"],
},
disabled: {
type: "boolean",
},
},
render: ({ container, props, width, height }) =>
new Promise((res) => {
ReactDOM.render(
<CustomButton
{...props}
style={{
width: width && `${width}px`,
height: height && `${height}px`,
}}
/>,
container,
() => res(() => ReactDOM.unmountComponentAtNode(container))
);
}),
},
]);