Skip to content

Getting a warning even when passing AccessibilityState as an object #121

Closed
@Kamalnrf

Description

@Kamalnrf
const accessibilityState: AccessibilityState =
      disabled !== props.accessibilityState?.disabled
        ? {...props.accessibilityState, disabled, busy: loading}
        : {...props.accessibilityState, busy: loading}

This is how we are computing the accessibility state in a component. We see a warning triggered by react-native-a11y/has-valid-accessibility-state saying the passed value is not an object in the attached screenshot.

Screen Shot 2021-07-01 at 16 35 11

When we change the prop value to an empty object {} the warning seems to go away. Still, changing the accessibilityState variable value to an empty object, we see the warning again.

const accessibilityState = {}

The expected behavior is that we shouldn't see this warring as the value of accessibilityState is an object in both snippets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions