Skip to content

docs(components/cdk/scrolling): add note about view recycling with dy… #19245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

michaelsanford
Copy link

…namic components

Added a clearer note about the behaviour of view recycling in cdk-virtual-scroll-viewport
containers when rendering dynamic components.

Fixes #15838

…namic components

Added a clearer note about the behaviour of view recycling in cdk-virtual-scroll-viewport
containers when rendering dynamic components.

Fixes #15838
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 3, 2020
@Santalov
Copy link

Santalov commented Jul 9, 2021

Hello, can you clarify that statement a bit, please? Really need it.

What exactly the state preservation means? Does it mens that in this code location binding will never change?

<cdk-virtual-scroll-viewport
        [itemSize]="itemSize"
        [minBufferPx]="itemSize * 2"
        [maxBufferPx]="itemSize * 4"
>
        <div
          *cdkVirtualFor="let location of locations"
          [style.height]="itemSize + 'px'"
        >
          <app-location-card
            [location]="location"
          >
          </app-location-card>
        </div>
</cdk-virtual-scroll-viewport>

@michaelsanford
Copy link
Author

What exactly the state preservation means?

The behaviour is discussed n the linked issue which this PR closes, with examples.

Are you suggesting the change to the documentation is not clear enough and could be improved?

@andrewseguin andrewseguin removed the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 28, 2021
@@ -56,6 +56,9 @@ is reused instead. The size of the view cache can be adjusted via the `templateC
property; setting this size to `0` disables caching. If your templates are expensive in terms of
memory you may wish to reduce this number to avoid spending too much memory on the template cache.

Recycled components within the `<cdk-virtual-scroll-viewport>` preserve state like bound parameter values.
When rendering dynamic components, you may want to disable caching completely.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding to the docs. Based on your initial issue it looks like a lot of people would benefit from this sort of messaging. However, I don't think "dynamic components" will be clear enough. Is there another way to describe what users should watch out for in more Angular-ish terms? Should users specifically be careful about components not calling their constructor or ngOnInit when reused?

@josephperrott josephperrott deleted the branch angular:master April 28, 2022 17:43
@devversion
Copy link
Member

Hey, please re-open the pull request if still valid. The PR got auto-closed by GitHub when we renamed our primary branch.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdk-virtual-scroll: newly-rendered list items seem to inherit internal state from the _templateCache
6 participants