I have some problems getting props value (that is array actually) into my composition api (setup). So I have component that is called DropDown, and I'm passing it some array of objects, and I need to do something like this:
export default {
emits: ['update:modelValue'],
props: {
items: {
type: Array,
// required: true
},
modelValue: {
type: [String, Number, Boolean],
required: true
}
},
setup({modelValue, props} : any, {emit} : any ) {
let is_active = ref(false);
let selected = ref({
label: props.items[0].label,
icon: props.items[0].icon,
class: props.items[0].class
});
as you see I have let selected that must have first object of items array, but it's not working. I'm listing items without problem on my template, but on setup I can't.
Any ideas how to fix it?
btw: Best practise is to use like let selected = reactive(props.items[0]) but, it's not working like this as well.