How to Re-render a View in SwiftUI
If you want to just render the same view, for some reasons (for example, you just show a different timestamp, like the example I show below), there is no direct way but a quick way to implement this.
The approach can be summarized as: turn the view you want to re-render to a view itself and pass the variable to it. Whenever the variable changes, it triggers the view to render again.
In the code above, whenever the list is pulled down, it triggers the method refreshable() and refreshCounter will increment. Since refreshCounter changes, it triggers the child view WorkHistoryEntryView to re-draw.
I wish there were a more direct SwiftUI API to accomplish this. But this does the trick. Enjoy!
(My latest book “macOS App Development: The SwiftUI Way” is now available. Grab your copy today!)