Keep scroll-y after rerender

后端 未结 2 1238
既然无缘
既然无缘 2021-01-04 09:13

I have dropdown list with a lot of checkboxes, so this container has scroll. But when i click on any checkbox - it selects\\deselects itself and then state changes.

2条回答
  •  难免孤独
    2021-01-04 10:00

    It's happening because you are re-rendering the complete list of the checkboxes.

    There are 2 possible approaches:

    1. Re-render only relevant checkbox
    2. Save the scroll position of the container and update it once component is re-rendered.

    Unfortunately, you haven't added any code examples, so can't share the code changes.

提交回复
热议问题