I am learning interactivity API and when I tried wp-each directive, I noticed that there is no way to get the index of the array. e.g. If this is my array
$config = [
'fruits' => [
[
'id' => time() * 1000,
'data' => [
'apple' => 10,
'orange' => 10,
'banana' => 10,
],
],
],
];
and this my HTML
render.php
<ul data-wp-interactive="myNameSpace"
class="gap-2 grid"
<?php echo wp_interactivity_data_wp_context( $config ) ?>
>
<template data-wp-each="context.fruits"
data-wp-key="context.item.id">
<li class="p-2 border border-slate-100 rounded-md"
data-wp-bind--id="context.item.id">
<span data-wp-text="context.index"></span>
</li>
</template>
</ul>
I checked the documentation and it does not include anything related to index.