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

has-valid-accessibility-actions rule doesn't accept variables #108

Closed
JCMartell opened this issue Feb 13, 2021 · 0 comments · Fixed by #113
Closed

has-valid-accessibility-actions rule doesn't accept variables #108

JCMartell opened this issue Feb 13, 2021 · 0 comments · Fixed by #113

Comments

@JCMartell
Copy link

Hi,

I was fixing some lint errors and encountered this situation:

const onAccessibilityAction = (event: { nativeEvent: { actionName: any } }) => {
    switch (event.nativeEvent.actionName) {
        case "delete":
            deleteAction();
            break;
        default:
            Alert.alert("Some text);
    }
}

const accessibilityActionsList: Array<{ name: string, label: string }> = [{ name: "delete", label: "Delete" }];

<TouchableOpacity
    accessibilityActions={accessibilityActionsList}
    onAccessibilityAction={onAccessibilityAction}
>
    ...
</TouchableOpacity>

Here, the has-valid-accessibility-actions rule throws the following errors: accessibilityActions: value must be an Array and accessibilityActions: has accessibilityActions but onAccessibilityAction is not a function. However, both of my variables have the correct types. I tried putting the array and the function as is in the JSX (without putting them in a variable) and it worked fine, but I prefer having a simpler/cleaner JSX.

Do you think this is something that can be fixed?

@JCMartell JCMartell changed the title The has-valid-accessibility-actions rule doesn't accept variables has-valid-accessibility-actions rule doesn't accept variables Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant