Socket
Socket
Sign inDemoInstall

@macaron-app/register-external-components

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @macaron-app/register-external-components

Register external components for Macaron


Version published
Maintainers
1
Created

Readme

Source

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([
  {
    // Exported .macaron.js files will include `import {CustomButton} from "./path/to/CustomButton";`

    // The import path of the component (relative to the **bundled** render scirpt file)
    importPath: "./path/to/CustomButton",
    // The import name of the component (if not specified, default import is used)
    importName: "CustomButton",

    // The props of the component
    props: {
      children: {
        type: "string",
      },
      type: {
        values: ["primary", "secondary"],
      },
      disabled: {
        type: "boolean",
      },
    },

    // Renders the component
    render: ({ container, props, width, height }) =>
      new Promise((res) => {
        ReactDOM.render(
          <CustomButton
            {...props}
            style={{
              width: width && `${width}px`,
              height: height && `${height}px`,
            }}
          />,
          container,
          // Asynchronously returns the cleanup function
          () => res(() => ReactDOM.unmountComponentAtNode(container))
        );
      }),
  },
]);

FAQs

Last updated on 29 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc