Skip to content

unexpected behavior with componentWillRender #2061

@vidarc

Description

@vidarc

Stencil version:

 @stencil/core@1.8.1

I'm submitting a:

[ x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
Changing various props in sequential lines, does not produce expected results with componentWillRender and shouldComponentUpdate.

What I am doing is updating the props, first, middle, and last, inside a click handler. The change to first triggers the componentWillRender lifecycle as I would expect, as well as the componentShouldRender lifecycle. However, you do not get those for the other two prop changes, even though they are properly changed by the time you get to the render method.

Logs of what is happening.
Screen Shot 2019-12-04 at 10 00 10 PM

Expected behavior:
I would expect either the prop changes to be batched somehow, seeing as they are modified very quickly, or for there to be some way to capture all the changes before the render method.

In my actual code at work, I need to compute some data before render based upon two props. Would it just be better to always do that type of stuff inside the render method then? Seems to be the only place I have a guarantee to their values right now, but worry it might be costly.

Steps to reproduce:

Related code:

Repo with example code: https://github.com/vidarc/stencil-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions