Course contentsShow
← React Native
Lesson 33 of 1,5551. The React Native ArchitectureFree lesson

Accessibility Tree Mapping

You will be able to map React component semantic properties to native accessibility protocols like VoiceOver and TalkBack.

In this lesson, you will learn how React Native translates your component logic into the accessibility structures that screen readers like VoiceOver (iOS) and TalkBack (Android) use to interpret your app.

The Bridge Between Semantic and Native

When you build a UI in React Native, you are essentially defining a "Shadow Tree" that eventually renders native views. However, visually impaired users often navigate this tree using assistive technologies. Accessibility Tree Mapping is the process where React Native’s internal architecture takes your component’s semantic properties—like accessible, accessibilityLabel, and accessibilityRole—and projects them into a parallel tree structure that the operating system can read.

Think of it this way: your React code describes what an element is, and the Accessibility Tree Mapping system translates that into the language the native OS expects.

How Mapping Works

When you set accessibilityRole="button" on a TouchableOpacity, React Native doesn't just send a generic view to the screen. It informs the native UI Manager that this specific view should be treated as a UIButton (on iOS) or a Button (on Android).

Consider this snippet:

<TouchableOpacity 
  accessible={true} 
  accessibilityLabel="Submit your order" 
  accessibilityRole="button"
>
  <Text>Submit</Text>
</TouchableOpacity>

When this component is committed to the UI Manager, the following mapping occurs:

  1. The Semantic Layer: Your React code attaches metadata.
  2. The Mapping Process: The framework identifies the native platform.
  3. Native Protocol:
    • On iOS, it maps to the UIAccessibility protocol, setting the accessibilityLabel property of the UIView.
    • On Android, it maps to the AccessibilityNodeInfo object, which TalkBack reads to announce "Button, Submit your order."

Without this mapping, the screen reader might only announce "Group" or "View," leaving the user lost. By mapping these properties, you ensure that the native accessibility service receives a high-fidelity representation of your UI, allowing it to provide meaningful audio feedback based on the exact platform-native protocols.

Key Takeaway: Accessibility Tree Mapping is the critical bridge that converts your React-defined semantic properties into the specific language required by iOS VoiceOver and Android TalkBack to ensure every user can interact with your application.