Complete the code to swap two instances in Figma using the plugin API.
const temp = instance1.[1]; instance1.[1] = instance2.[1]; instance2.[1] = temp;
In Figma plugin API, swapping instances involves exchanging their mainComponent property.
Complete the code to replace an instance with another component in Figma.
instance.[1] = newComponent;To replace an instance's component, assign the new component to its mainComponent property.
Fix the error in swapping two instances' components.
const temp = instanceA.[1]; instanceA.[1] = instanceB.[1]; instanceB.[1] = temp;
The correct property to swap is mainComponent. Other options are invalid or do not exist.
Fill both blanks to swap the main components of two instances safely.
const [1] = instanceX.[2]; instanceX.[2] = instanceY.[2]; instanceY.[2] = [1];
Use a temporary variable temp to hold the mainComponent while swapping.
Fill all three blanks to create a function that swaps the main components of two instances.
function swapInstances(inst1, inst2) {
const [1] = inst1.[2];
inst1.[2] = inst2.[2];
inst2.[2] = [1];
}The function uses a temporary variable temp to hold the mainComponent property while swapping.