Home App Docs Blog Github

Getting index of a repeated element

Hi there,

I’m using a state array variable to repeat an “Input” element. E.g. state.itemsArray. I’ll like to set the value of the “Input” element to be the value of each item in state.itemsArray. This can be achieved by referencing state.itemsArrayItem.

However, onChange of any “Input” element, I’ll like to update that respective index’s item of state.itemsArray. I am unable to reference the index of a repeated element however. Would someone be able to direct me to how this may be done?

TLDR: How do I access the index of a particular element within a repeated element?


Hey @maltase, you should be able to use state.$index to achieve what you’re looking for! Let me know if you have any additional questions.

That’s awesome. Thanks!

1 Like