# Clone Component based on length of list

**URL:** <https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027>\
**Category:** Questions about Thunkable X\
**Created:** [August 8, 2019, 11:25am UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027 "2019-08-08T11:25:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jacob1](https://community.thunkable.com/u/jacob1)\
**Post date:** [August 8, 2019, 11:25am UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/1 "2019-08-08T11:25:43Z")

</div>

Hi All,

I’m using the new clone block in my app, when the screen opens I pull data back from firebase and put it in a list, I then clone blocks to hold that data, does anybody know how to clone only new items from firebase, whenever the screen opens it just keeps cloning everything

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [August 8, 2019, 1:14pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/2 "2019-08-08T13:14:32Z")

</div>

Hi

What is the difference between new elements and old ones? If there is such a difference, then using the conditional block you can create an algorithm for copying only new components.

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [August 8, 2019, 3:06pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/3 "2019-08-08T15:06:59Z")

</div>

like make a comparison from the lenght of the old list with the lenght of the new list and if it’s longer only get the difference elements?

---

<div class="post-metadata">

**Author:** ![jacob1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jacob1](https://community.thunkable.com/u/jacob1)\
**Post date:** [August 8, 2019, 11:13pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/4 "2019-08-08T23:13:16Z")

</div>

Thank you for your responses, the difference in the components will be the different data being pulled from firebase,

I did think of getting the length of the list and then if the length changes using the clone component. However - even if the list doesn’t change I will still need to use the clone component, and so everytime I open the screen it is still recloning,

Does anybody have any block examples on this?

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [August 11, 2019, 10:58am UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/5 "2019-08-11T10:58:06Z")

</div>

I don’t understand your problem and what you want your app to do.

If you are saying that the appa clones ALL the list components everytime you open the screen, you need to use the block named ’ when screen STARTS’, and not opens, that will clone the list only the first time it’s opened and not everytime

---

<div class="post-metadata">

**Author:** ![jacob1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@jacob1](https://community.thunkable.com/u/jacob1)\
**Post date:** [August 12, 2019, 6:40am UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/6 "2019-08-12T06:40:15Z")

</div>

Hi Max,

Thank you for your comment, however this wouldn’t work because I want the screen to show all the latest entries when the screen opens, if I do it just on screen starts, and then a new entry is available, it won’t show it unless the user exits and restarts the app, in this case I have used a measure to find the length of the list and if variable is greater than length of list I will add it,

Thank you for your help

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [August 12, 2019, 3:11pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/7 "2019-08-12T15:11:24Z")

</div>

First: If the data comes from firebase, there is the “when data changes” block that will trigger only if data has changed, in that case you could add the cloned… Ok I think I get your problem and in any case you could delete all the already cloned blocks and clone them from the start whenever a new data is added/changed.

I think you could create a more complex solution to only add the new entries to the already cloned ones, but to be honest, I have to work on my app and can’t really think too much about yours ^^

Hope this helped a little

---

<div class="post-metadata">

**Author:** ![jamesx](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jamesx](https://community.thunkable.com/u/jamesx)\
**Post date:** [June 12, 2020, 5:20pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/8 "2020-06-12T17:20:01Z")

</div>

Hi @jacob1

Sorry, a little late to this party! I’ve been playing with clones using AirTable, but I suspect that the solution for Firebase would be very similar.

In my example, I want to find each row that has the name “supersets” (I’m building a workout app), so I used the Control block “for each item J” in whatever is returned to check and see whether there is a match. Where there is a match I’ve used the Any Component blocks to change the content of the cloned elements.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/c/bc51a2155cb7b547f7c690800b3e66136f4ee52f.png)

Please feel free to remix what I’ve done - [Thunkable](https://x.thunkable.com/copy/8690263115fd78914a006f01d1640e72)

Hope this helps.

James

---

<div class="post-metadata">

**Author:** ![maxb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/maxb/32/35200_2.png) [@maxb](https://community.thunkable.com/u/maxb)\
**Post date:** [July 2, 2020, 4:26pm UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/9 "2020-07-02T16:26:43Z")

</div>

You could just delete the cloned components and clone them again if the lenght of the list changes

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:25am UTC](https://community.thunkable.com/t/clone-component-based-on-length-of-list/174027/10 "2024-11-08T11:25:09Z")

</div>


