How to find the child element quickly?


In my plugin, there is a list of elements. Where the user clicks on any element, the element should be focused on.

Right now I’m saving the ids of nodes, and then calling the node.findOne function:

// id is known
let node = figma.currentPage.findOne(n => === id);
figma.currentPage.selection = [node];

But as it said in the docs, the search with node.findOne can be slow when used on large Figma projects.

How can I speed up this process? Should I save the node objects when forming the list, or there is a better way?

I’d really appreciate it if you would help!

by caching or by searching asychronously (this is more for not blocking user)

1 Like

Thank you for your reply :slight_smile:

Check out this thread: Figma layers tree traversal + estimating size