Skip to content

Instantly share code, notes, and snippets.

@patskovn
Last active September 7, 2021 10:48
Show Gist options
  • Select an option

  • Save patskovn/487a71359142d7c9f17bcfbbaa73874e to your computer and use it in GitHub Desktop.

Select an option

Save patskovn/487a71359142d7c9f17bcfbbaa73874e to your computer and use it in GitHub Desktop.
Text is always "Title is empty"
import SwiftUI
import ComposableArchitecture
struct TestState: Equatable {
@BindableState var value = ""
}
enum TestAction: BindableAction {
case binding(BindingAction<TestState>)
}
let testReducer = Reducer<TestState, TestAction, Void> { state, action, env in .none }
struct WrappingView: View {
let store: Store<TestState, TestAction>
var body: some View {
WithViewStore(store) { viewStore in
TestView(text: viewStore.$value)
}
}
}
struct TestView: View {
@Binding var text: String
var body: some View {
VStack {
// Text is always "Title is empty"! Typing does not triggersing redraws in new approach
Text(text.isEmpty ? "Title is empty" : "Title is not empty")
TextField("Title", text: $text)
.background(Color.yellow)
}
}
}
@patskovn
Copy link
Author

patskovn commented Sep 7, 2021

Tried with:
Xcode 12.5.1 (12E507), iOS 14.6
Xcode 13.0 beta iOS 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment