You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran into a bug while using @saasquatch/stencilbook -- the component renders in dev mode, but when built for production the component will not re-render when state changes.
Upon deeper investigation the forceUpdate method from @stencil/core is being called, but render never gets called again.
By looking into the source of forceUpdate, it relies on an isUpdateable flag or becomes a no-op:
To reproduce, do a production build on this component:
import{withHooks,useState}from'@saasquatch/stencil-hooks';
@Component({tag: 'my-counter',})exportclassCounter{constructor(){withHooks(this);}render(){const[count,setCount]=useState(0);return(<div>{count}<buttononClick={()=>setCount(count+1)}>+1</button></div>);}disconnectedCallback(){// required for `useEffect` cleanups to run}}
To fix add any unused prop or state.
import{withHooks,useState}from'@saasquatch/stencil-hooks';
@Component({tag: 'my-counter',})exportclassCounter{
@Prop()unusedButAllowsForceUpdate=true;// ... rest of component ...}
The text was updated successfully, but these errors were encountered:
Ran into a bug while using @saasquatch/stencilbook -- the component renders in dev mode, but when built for production the component will not re-render when state changes.
Upon deeper investigation the
forceUpdate
method from@stencil/core
is being called, butrender
never gets called again.By looking into the source of
forceUpdate
, it relies on anisUpdateable
flag or becomes a no-op:Deeper introspection shows this telling line:
To reproduce, do a production build on this component:
To fix add any unused prop or state.
The text was updated successfully, but these errors were encountered: