Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Sources/FlowStack/FlowLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ struct GestureContainer: UIViewRepresentable {
return button
}

func updateUIView(_ uiView: UIViewType, context: Context) { }
func updateUIView(_ uiView: UIViewType, context: Context) {
// The coordinator is made once and reused for the life of the
// representable, so without this the button keeps calling the very
// first onTap it was given — and that closure captured the FlowLink
// as it was on its first render, including its `value` and its
// `label`. A link whose row is refreshed in place (a cached list
// replaced by a fetched one, a count that moves) then pushes the
// stale value and snapshots the stale label, no matter how many
// times SwiftUI re-renders it.
context.coordinator.onTap = onTap
}

func makeCoordinator() -> Coordinator {
Coordinator(isPressed: $isPressed, onTap: onTap)
Expand Down