Passing Arrays to Components
Development
Investigating How to pass an array of values into an Astro component
The process of passing an array of values arround in Astro seemed as though it should be really straight forward, but!
Well I tried passing it as an array val[]
, no luck an error with the format of the argument. So just pass val
and recieve it as an array? Still no luck.
When I did finally get the values I needed passed to the component I got the ‘map is not a function’ error.
Finally by passing the values I needed as an array as a comma separated string and the using code below in the code fence I got it to work :)
if (typeof tags !== 'undefined') {
var tagsarr = tags.split(',');
console.log(tagsarr);
}
And so move on…