Posts

Post marked as solved
1 Replies
369 Views
my class contains a function, class UserModel: ObservableObject { func fetchUser(){ // code } } i call this class in a struct struct UserView: View { @StateObject var userModel = UserModel() @State var loading: Bool = false var body: some View { ButtonComponent(loading: $loading) } } I would like to access the class in ButtonComponent just like i did with the loading variable by binding it. The ButtonComponent is like this.. struct ButtonComponent: View { @Binding var loading: Bool var body: some View { Button(action: {loading.toggle()}){ Text("Submit Button") } } } Help on how to achieve this is appreciated
Posted
by coucoseth.
Last updated
.