I have declared a const 'offset', and when I try to fetch this and update in a function , the value is undefined. Hence I wont be able to add value to const. Below is sample code
import { LightningElement, wire, track , api } from 'lwc';
import getContractWithDetails from '@salesforce/apex/AccountContactController.getContractWithDetails';
const offset = 0;
export default class WrapperClassExampleLWC extends LightningElement {
@track accountsWithContacts;
@track contractWithDetails;
handleScroll(event)
{
console.log(' stats :' , this.offset);
}
}
handleScroll func is called when the user performs a scrolling action, and every time the scroll bar is reached to the bottom I want to update the offset value to higher value (say for example 30 every time) and fetch new records from apex and append to the table, but above console log gives me stats :undefined , why is this value undefined ? although I can check if the value is undefined and update with required value as below, I want to understand why is this value undefined even though I have set it to 0 , any links and pointers to SF LWC variable documentation would be helpful.
if(this.offset == undefined)
{
this.offset = 0;
}
this.offset = this.offset + 30;