Why can't I make navigationLink normally without using IfLetStore??? #1048
-
NavigationLink(LocalizedStringKey.init("Hy"), destination: Text("Hiiii"), isActive: viewStore.binding(get: $0.canLogin, send: { LoginAction.validateCredentials() }))
Button("Login") {
viewStore.send(.validateCredentials)
}.frame(width: 200, height: 40, alignment: .center)
.foregroundColor(.black)
.background(!viewStore.canLogin ? .green.opacity(0.3): .green.opacity(1))
.disabled(!viewStore.canLogin)
.cornerRadius(20)
.padding() When writing above code its not working in TCA. Please help me out...Getting Error: Contextual closure type '() -> TupleView<(NavigationLink<EmptyView, Text>, Button<Text>)>' expects 0 arguments, but 1 was used in closure body |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi, Alternatively, you could probably use Also, By the way, you can preserve your code formatting by using a triple "`" instead of a single one, and add "swift" to get code highlighting:
I hope it'll help! |
Beta Was this translation helpful? Give feedback.
Hi,
It looks like a standard Swift error message. It seems that
$0.canLogin
misses its enclosing curly braces:{ $0.canLogin }
. It also seems that you're using the deprecated version of this initializer that you should preferably use.Alternatively, you could probably use
\.canLogin
instead{ $0.canLogin }
, because theKeyPath<State, Bool>
is automatically promoted as a function(State) -> Bool
equivalent to{ $0.canLogin }
. That's maybe where things were mixed up.Also,
LocalizedStringKey
isExpressibleByStringLiteral
, so you should directly use"Hy"
.By the way, you can preserve your code formatting by using a triple "`" instead of a single one, and add "swift" to get code highlighting: