I have a sort filter that takes an array to populate the parameters. Trying to see the value parameter equal to the text inside the array, but I get an error in the header:
Invalid attempt to destructure non-iterable instance
I need to pass the text as the value in the parameter tag, so that when updating the filter, the correct text is displayed on the user selected.
Here is my code:
function Sorting({by, order, rp}: SortingProps) { const opts = [ ['Price (low)', 'price', 'asc'], ['Price (high)', 'price', 'desc'], ['Discount (low)', 'discount', 'asc'], ['Discount (high)', 'discount', 'desc'], ['Most popular', 'arrival', 'latest'], ['Most recent', 'arrival', 'latest'], ]; const onChange = (i) => { const [text, by, order] = opts[i]; refresh({so: {[by]: order}}); ga('send', 'event', 'My Shop Sort By', text, 'Used'); }; return ( <div className={cn(shop.sorting, rp.sorting.fill && shop.sortingFill)}> <Select className={shop.sortingSelect} label="Sort By" onChange={onChange} value={`${by}:${order}`}> {opts.map(([text], i) => <Option key={i} value={text}>{text}</Option> )} </Select> </div> ) }
Filth source share