A solution that would solve at least part of the problem described with regard to exclusive code for SwiftUI previews:
Give us a way to annotate code so that it can only be used within #Preview macros.
I.e. sth. that prevents this code from "accidentally" being used in regular / production builds.
Post
Replies
Boosts
Views
Activity
Your answer and description of onAppear raises a few questions.
Please note that the problem I described did not refer to the fact that no scrolling process may be triggered. This part works in the demo code and is not the actual issue.
The main problem is that the change of state1 back to false in the defer code block does not update the view accordingly.
This does not happen if you remove the scrollTo call in the onAppear method.
Do you have an explanation for this?