✅ I SOLVED IT: How to use Components like "Pre-Comps"? Nested Component use the same VM?
EDIT: I solved this! I wrote up a TLDR here at the top. Hopefully it helps someone
If you have a artboard that is getting complex, you can separate some elements into their own separate artboard components.
You already have your main artboard and its vm. Now create an additional artboard with its own VM.
Add that nested component into your main artboard. The instance data wont populate the nested component part of your main artboard yet.
The Solution: in your main artboard, create a view model property of your component’s view model. Then select your nested component, and bind it to it’s vm that you nested inside of your main vm.
I don’t get the logic behind it, but it seems to work!
—————————
I have a component (ScoreCard) in a artboard list on my “Main” board. Each card can fill the two numbers with data.
This works great.
However, sometimes an artboard gets very busy with items. For a complex area of the board, I’d like to break out a section to have its own component artboard with its own layers and hierarchy.
I made a simplified example (screenshot and .rev below).
I’d like the two numbers to be on their own component board. This is the NumbersBox component in the example. It is the same as the original numA numB in the working example above, but now they are on their own board (and have a pink background).
However, when I add the component to the Score Card they no longer connect to the “scoreCard” VM data. I tried giving numbersBoxVM a property of “scoreCard” VM (where the scorecard data exists) but it isn’t passing the values.
Is this possible to do? Is there a name for this concept, or a tutorial/thread on how to do it? I feel like it is a simple idea but I havent been able to find an example of it
Thank you for any help