Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving "does not have 'onChange' modifier" after updating to onChange(of:, _ action:) from onChange(of:, perform:) #330

Closed
Rob-2024 opened this issue Sep 5, 2024 · 2 comments
Labels
feature request New feature or request

Comments

@Rob-2024
Copy link

Rob-2024 commented Sep 5, 2024

I have updated the existing onChange(of:, perform:) which is deprecated in v17 to onChange(of:, _ action:). Now ViewInspector doesn't recognize callOnChange reporting "does not have 'onChange' modifier"`. Here is an example of the error. How can I get these tests working again?

`
func testOnCall() throws {
struct TestView: View {
@State var inputValue: String = ""
@State var displayValue: String = ""
var body: some View {
VStack {
Text(displayValue)
TextField("Test Input", text: $inputValue)
}
.onChange(of: inputValue, { old, new in
displayValue = "Was (old.count > 0 ? old : "N/A") and now is (new.count > 0 ? new : "N/A")"
})
}
}

    let test = TestView()
    XCTAssertNoThrow(try test.inspect().callOnChange(newValue: "Bob"))
    XCTAssertNoThrow(try test.inspect().vStack().callOnChange(newValue: "Bob"))
    XCTAssertNoThrow(try test.inspect().find(ViewType.VStack.self).callOnChange(newValue: "Bob"))
}

`

@andy-vanwagoner-jn
Copy link
Contributor

I added support for the new modifier with .callOnChange(oldValue:newValue:). I don't think there has been a release, so you may need to point to a branch or a commit after the feature was added.

@nalexn nalexn added feature request New feature or request pending release A fixed issue that'll be released in an upcoming update labels Sep 6, 2024
@nalexn
Copy link
Owner

nalexn commented Sep 17, 2024

Released with v0.10.0

@nalexn nalexn closed this as completed Sep 17, 2024
@nalexn nalexn removed the pending release A fixed issue that'll be released in an upcoming update label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants