I am using global variable @api filter in wire method in child component. Defined this variable with default value="". I am passing value say 'xyz' to this filter parameter from parent lwc component. When the child component is called sometimes the variable showing "" and sometimes showing "xyz". Why there is inconsistency and how to make this variable to have value what i assigning from Parent Component. Below is the code:
@api filter ="";
@wire(getContactList)
wiredContacts({ error, data }) {
if (data) {
const filter = this.filter;
console.log('filterval'-->filter);--->displaying "" instead of "xyz"
this.error = undefined;
} else if (error) {
this.error = error;
this.contacts = undefined;
}
}