Within my Stencil component, there exists a not-Prop member variable known as private _zIndex
. The value of this variable can be adjusted via a method call like
Method() setZIndex( zIndex : number );
, or it may change internally during the component's operations. I'm in need of a way to access the current value of this variable externally. My attempt was to create a method that simply return this._zIndex
. However, this method needs to be asynchronous due to a warning:
The external @Method() getZIndex() should return a Promise or void.
Consider prefixing the method with async, Next minor release will error.
I prefer not to make the getZIndex() function asynchronous, so another approach is to define a
Prop( { mutable: true } ) _zIndex
. This allows me to set and retrieve the variable's value, but the downside is that each time the variable is updated, it triggers a re-render of the stencil component. Given the size of my component and its complex structure, this process becomes slow.
My query is whether there are alternative methods available:
- To extract the private variable's value externally without introducing an asynchronous operation?
or
- To configure a Prop in a way that prevents a re-render when its value is modified?