React-native-paper: react-native 0.62.x removed accessibilityStates

Created on 16 May 2020  路  10Comments  路  Source: callstack/react-native-paper

Environment

  • react: 16.11.0
  • react-native: 0.62.2
  • react-native-paper: 3.10.1
  • typescript: 3.9.2

Description

Remove accessibilityStates: We鈥檝e removed the deprecated accessibilityStates property in favor of the new accessibilityState prop which is a more semantically rich way for components to describe information about their state to accessibility services.
-- https://reactnative.dev/blog/#breaking-changes

image

Reproducible Demo

Code:

import React from "react"
import { View } from "react-native"
import { Text } from "react-native-paper"

interface Props {}

const Component: React.FC<Props> = () => {
  return (
    <View>
      <Text>Component</Text>
    </View>
  )
}

export default Component
Stale

Most helpful comment

A way to IGNORE errors using patch-package:

diff --git a/node_modules/@types/react-native/index.d.ts b/node_modules/@types/react-native/index.d.ts
index 98681f1..825c536 100644
--- a/node_modules/@types/react-native/index.d.ts
+++ b/node_modules/@types/react-native/index.d.ts
@@ -2069,6 +2069,7 @@ export interface AccessibilityProps extends AccessibilityPropsAndroid, Accessibi
      * Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on.
      */
     accessibilityState?: AccessibilityState;
+    accessibilityStates?: any; // react-native-paper 3.x
     /**
      * An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label.
      */

Put this file to patches/@types+react-native+0.62.11.patch, run yarn patch-package.

NOTE: This just ignores the error, accessibilityStates does not work as expected.

All 10 comments

This is a real issue

I was about a start a project and faced this issue :cry: . Hope it will be fixed soon.

I Hope that a fix will be published soon..

Hey, thanks for messages.
To solve this issue we need to upgrade types for react-native also but It's abreaking change so we will publish this change in 4.0 since we have users with older versions of react than 0.6.

What's the timeline for the release of 4.0? Any chance of getting the updated types some other way if that's not happening very soon?

This is not a fix.... however I've removed all occurrences of '"accessibilityStates" | ' in ./node_modules/react-native-paper/lib/typescript, which makes the annoying errors go away.

Don't follow my advice, I know nothing.

A way to IGNORE errors using patch-package:

diff --git a/node_modules/@types/react-native/index.d.ts b/node_modules/@types/react-native/index.d.ts
index 98681f1..825c536 100644
--- a/node_modules/@types/react-native/index.d.ts
+++ b/node_modules/@types/react-native/index.d.ts
@@ -2069,6 +2069,7 @@ export interface AccessibilityProps extends AccessibilityPropsAndroid, Accessibi
      * Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on.
      */
     accessibilityState?: AccessibilityState;
+    accessibilityStates?: any; // react-native-paper 3.x
     /**
      * An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label.
      */

Put this file to patches/@types+react-native+0.62.11.patch, run yarn patch-package.

NOTE: This just ignores the error, accessibilityStates does not work as expected.

@ianmartorell, for now, we can say the end of June

@firede Awesome! It's fixed and it's working! Thank you for code and instruction!

Hello 馃憢, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

Was this page helpful?
0 / 5 - 0 ratings