Skip to main content
Question

Console error after using importComponentByKeyAsync(key)


James_Grubb1

Hi my plugin currently places an instance from my library on the page. If I then click and move the instance console reports the following error

caught Error: "Variable data not found in consumption map entry" in buildUpdateForUI (FGDerivedSelectionProperties.cpp)
    at _reportError (compiled_wasm.js.br:2:108334)
 

here is the code:

   const componentKey = "b46ad4dd5247c059da9597e511b2042814ccc0f4";

   // Obtain the page where you want to place the component
   const targetPage = figma.currentPage;
  function placeLogo() {
    figma
      .importComponentByKeyAsync(componentKey)
      .then((component) => {
        // Create an instance of the component on the target page
        console.log(component);
        const componentInstance = component.createInstance();
        // Set position and scale of the component instance
        componentInstance.x = 100; // X position
        componentInstance.y = 100; // Y position
        componentInstance.resize(200, 200); // Width and height

        // Add the component instance to the target page
        targetPage.appendChild(componentInstance);

        // Zoom to fit the added component instance
        figma.viewport.scrollAndZoomIntoView([componentInstance]);
        figma.closePlugin();
      })
      .catch((error) => {
        console.error("Error importing component:", error);
      });
  }

  placeLogo();

If i drag the same instance on to the page there are no subsequent errors.

Thanks in advance

This topic has been closed for replies.

2 replies

tank666
  • 4873 replies
  • June 22, 2023

This is an internal error of Figma, and does not apply to the Plugin API. Or is this error affecting your plugin?


James_Grubb1

Its not effecting the plugin but i’m worried Im not writing the code properly


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings