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.
You can save the "snapshot" of the scroll position before the commit phase.
getSnapshotBeforeUpdate() shows kind of what you are looking for.
The documentation example saves the current scroll position within getSnapshotBeforeUpdate
lifecycle method and then use the snapshot
value passed to componentDidUpdate(prevProps, prevState, snapshot)
as the last argument to restore the scroll position.
It doesn't require creating a state to save the scroll position as you requested.
It's happening because you are re-rendering the complete list of the checkboxes.
There are 2 possible approaches:
Unfortunately, you haven't added any code examples, so can't share the code changes.