### Install Azul Zulu JDK 17 and locate installation path Source: https://reactnative.dev/docs/set-up-your-environment Install the Azul Zulu OpenJDK 17 using Homebrew and then use `brew info` to find its installation directory, which is needed for manual installation or environment variable setup. ```bash brew install --cask zulu@17 # Get path to where cask was installed to find the JDK installer brew info --cask zulu@17 # ==> zulu@17: # https://www.azul.com/downloads/ # Installed # /opt/homebrew/Caskroom/zulu@17/ (185.8MB) (note that the path is /usr/local/Caskroom on non-Apple Silicon Macs) # Installed using the formulae.brew.sh API on 2024-06-06 at 10:00:00 # Navigate to the folder open /opt/homebrew/Caskroom/zulu@17/ # or /usr/local/Caskroom/zulu@17/ ``` -------------------------------- ### Install Node.js LTS and OpenJDK 17 with Chocolatey Source: https://reactnative.dev/docs/set-up-your-environment Run this command in an Administrator Command Prompt to install the recommended LTS version of Node.js and OpenJDK 17 using Chocolatey on Windows. ```cmd choco install -y nodejs-lts microsoft-openjdk17 ``` -------------------------------- ### Install Node and Watchman using Homebrew Source: https://reactnative.dev/docs/set-up-your-environment Use these commands to install Node and Watchman, essential tools for React Native development, via Homebrew on macOS or Linux. ```bash brew install node brew install watchman ``` -------------------------------- ### Example Platform-Specific File Naming Convention Source: https://reactnative.dev/docs/platform-specific-code Illustrates the file naming convention for platform-specific components, where `.ios.` or `.android.` extensions denote files intended for a particular operating system. ```JavaScript BigButton.ios.js BigButton.android.js ``` -------------------------------- ### Default Android SDK Installation Path Source: https://reactnative.dev/docs/set-up-your-environment This is the default installation path for the Android SDK on Windows. Verify this path in Android Studio settings under 'Languages & Frameworks' → 'Android SDK'. ```Shell %LOCALAPPDATA%\Android\Sdk ``` -------------------------------- ### Start Metro Bundler on Custom Port with npm Source: https://reactnative.dev/docs/troubleshooting Run the Metro bundler using npm on a port other than the default 8081, for example, 8088. ```bash npm start -- --port=8088 ``` -------------------------------- ### Start Metro Bundler on Custom Port with Yarn Source: https://reactnative.dev/docs/troubleshooting Run the Metro bundler using Yarn on a port other than the default 8081, for example, 8088. ```bash yarn start --port 8088 ``` -------------------------------- ### Default Android platform-tools Path on Windows Source: https://reactnative.dev/docs/set-up-your-environment This snippet shows the default installation path for Android platform-tools on Windows, which needs to be added to the system's Path environment variable. ```plaintext %LOCALAPPDATA%\Android\Sdk\platform-tools ``` -------------------------------- ### Set JAVA_HOME environment variable for Zulu JDK 17 Source: https://reactnative.dev/docs/set-up-your-environment Update your shell's configuration file (e.g., `~/.zshrc` or `~/.bash_profile`) to set the `JAVA_HOME` environment variable, pointing to the installed Zulu JDK 17. ```bash export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home ``` -------------------------------- ### ShellCommandUnresponsiveException Error Message Source: https://reactnative.dev/docs/troubleshooting Example of the ShellCommandUnresponsiveException error message encountered during task execution. ```text Execution failed for task ':app:installDebug'. com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException ``` -------------------------------- ### JavaScript Object Literal for Styling Source: https://reactnative.dev/docs/intro-react An example of a standard JavaScript object literal used to define style properties, typically passed as a prop. ```javascript {width: 200, height: 200} ``` -------------------------------- ### isAccessibilityServiceEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Check whether any accessibility service is enabled. This includes TalkBack but also any third-party accessibility app that may be installed. To only check whether TalkBack is enabled, use [isScreenReaderEnabled](#isscreenreaderenabled). Returns a promise which resolves to a boolean. The result is `true` when some accessibility services is enabled and `false` otherwise. ```APIDOC ## `isAccessibilityServiceEnabled()` ### Description Check whether any accessibility service is enabled. This includes TalkBack but also any third-party accessibility app that may be installed. To only check whether TalkBack is enabled, use [isScreenReaderEnabled](#isscreenreaderenabled). Returns a promise which resolves to a boolean. The result is `true` when some accessibility services is enabled and `false` otherwise. ### Signature static isAccessibilityServiceEnabled(): Promise; ``` -------------------------------- ### getRecommendedTimeoutMillis() Source: https://reactnative.dev/docs/accessibilityinfo Gets the timeout in millisecond that the user needs. This value is set in "Time to take action (Accessibility timeout)" of "Accessibility" settings. ```APIDOC ## `getRecommendedTimeoutMillis()` ### Description Gets the timeout in millisecond that the user needs. This value is set in "Time to take action (Accessibility timeout)" of "Accessibility" settings. ### Signature static getRecommendedTimeoutMillis(originalTimeout: number): Promise; ### Parameters - **originalTimeout** (number) - Required - The timeout to return if "Accessibility timeout" is not set. Specify in milliseconds. ``` -------------------------------- ### Get recommended accessibility timeout (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Retrieves the user's preferred accessibility timeout in milliseconds, as set in system settings. Returns the `originalTimeout` if no setting is found. ```React TSX static getRecommendedTimeoutMillis(originalTimeout: number): Promise; ``` -------------------------------- ### Detect iOS Major Version with Platform.Version in React Native Source: https://reactnative.dev/docs/platform-specific-code Parse `Platform.Version` to get the major iOS version number, enabling conditional code execution for specific iOS versions, like working around behavior changes in older versions. ```React TSX import {Platform} from 'react-native'; const majorVersionIOS = parseInt(Platform.Version, 10); if (majorVersionIOS <= 9) { console.log('Work around a change in behavior'); } ``` -------------------------------- ### Create a new Expo project Source: https://reactnative.dev/docs/environment-setup Use this command in your terminal to initialize a new React Native project with the Expo framework. ```bash npx create-expo-app@latest ``` -------------------------------- ### File structure for native-specific extensions Source: https://reactnative.dev/docs/platform-specific-code Illustrates how to organize files with `.js` and `.native.js` extensions for web and React Native bundling, respectively. ```plaintext Container.js # picked up by webpack, Rollup or any other Web bundler Container.native.js # picked up by the React Native bundler for both Android and iOS (Metro) ``` -------------------------------- ### Make gradlew Executable on macOS Source: https://reactnative.dev/docs/troubleshooting Command to make the `gradlew` file executable, resolving `spawnSync ./gradlew EACCES` errors on macOS. ```shell sudo chmod +x android/gradlew ``` -------------------------------- ### Configure NVM for Xcode with zsh Source: https://reactnative.dev/docs/set-up-your-environment Move NVM initialization code to `~/.zshenv` to help Xcode find your Node executable when using NVM and zsh. ```bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm ``` -------------------------------- ### Verify ANDROID_HOME in PowerShell Source: https://reactnative.dev/docs/set-up-your-environment Use this command in PowerShell to list environment variables and confirm that ANDROID_HOME has been successfully added. ```powershell Get-ChildItem -Path Env:\ ``` -------------------------------- ### announceForAccessibilityWithOptions() Source: https://reactnative.dev/docs/accessibilityinfo Post a string to be announced by the screen reader with modification options. By default announcements will interrupt any existing speech, but on iOS they can be queued behind existing speech by setting `queue` to `true` in the options object. ```APIDOC ## `announceForAccessibilityWithOptions()` ### Description Post a string to be announced by the screen reader with modification options. By default announcements will interrupt any existing speech, but on iOS they can be queued behind existing speech by setting `queue` to `true` in the options object. ### Signature static announceForAccessibilityWithOptions(announcement: string, options: {queue?: boolean}); ### Parameters - **announcement** (string) - Required - The string to be announced - **options** (object) - Required - `queue` - queue the announcement behind existing speechiOS ``` -------------------------------- ### Restart ADB Server Source: https://reactnative.dev/docs/troubleshooting Commands to restart the ADB server when encountering a ShellCommandUnresponsiveException. ```shell adb kill-server adb start-server ``` -------------------------------- ### announceForAccessibility() Source: https://reactnative.dev/docs/accessibilityinfo Posts a string to be announced by the device's screen reader. This can be used to provide important information to users with visual impairments. ```APIDOC ## `announceForAccessibility()` ### Description Posts a string to be announced by the device's screen reader. This can be used to provide important information to users with visual impairments. ### Signature `static announceForAccessibility(announcement: string);` ### Parameters - **announcement** (`string`) - Required - The string message to be announced by the screen reader. ### Returns `void` - This method does not return any value. ``` -------------------------------- ### Configure Android Environment Variables for React Native Source: https://reactnative.dev/docs/set-up-your-environment Add these lines to your shell configuration file (e.g., `$HOME/.bash_profile` or `~/.zprofile`) to set the `ANDROID_HOME` variable and extend your `PATH` for React Native development. ```bash export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/platform-tools ``` -------------------------------- ### Configure Android Environment Variables for React Native Source: https://reactnative.dev/docs/set-up-your-environment Add these lines to your shell configuration file (e.g., ~/.zprofile or ~/.bash_profile) to set ANDROID_HOME and extend your PATH for Android development tools. ```shell export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/platform-tools ``` -------------------------------- ### isGrayscaleEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether grayscale is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when grayscale is enabled and `false` otherwise. ```APIDOC ## `isGrayscaleEnabled()` ### Description Query whether grayscale is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when grayscale is enabled and `false` otherwise. ### Signature static isGrayscaleEnabled(): Promise; ``` -------------------------------- ### prefersCrossFadeTransitions() Source: https://reactnative.dev/docs/accessibilityinfo Query whether reduce motion and prefer cross-fade transitions settings are currently enabled. Returns a promise which resolves to a boolean. The result is `true` when prefer cross-fade transitions is enabled and `false` otherwise. ```APIDOC ## static prefersCrossFadeTransitions(): Promise ### Description Query whether reduce motion and prefer cross-fade transitions settings are currently enabled. Returns a promise which resolves to a boolean. The result is `true` when prefer cross-fade transitions is enabled and `false` otherwise. ### Method Name prefersCrossFadeTransitions ### Return Value - **Promise** - Resolves to `true` if prefer cross-fade transitions are enabled, `false` otherwise. ``` -------------------------------- ### isDarkerSystemColorsEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether dark system colors is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when dark system colors is enabled and `false` otherwise. ```APIDOC ## static isDarkerSystemColorsEnabled(): Promise ### Description Query whether dark system colors is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when dark system colors is enabled and `false` otherwise. ### Method Name isDarkerSystemColorsEnabled ### Return Value - **Promise** - Resolves to `true` if dark system colors are enabled, `false` otherwise. ``` -------------------------------- ### Load Native or Web Components with Platform.select in React Native Source: https://reactnative.dev/docs/platform-specific-code Use `Platform.select` with `native` and `default` keys to load a component specifically for native platforms (iOS/Android) or a fallback for other platforms like web. ```React TSX const Component = Platform.select({ native: () => require('ComponentForNative'), default: () => require('ComponentForWeb'), })(); ; ``` -------------------------------- ### Post a string announcement for the screen reader Source: https://reactnative.dev/docs/accessibilityinfo Posts a string to be announced by the device's screen reader. ```React TSX static announceForAccessibility(announcement: string); ``` -------------------------------- ### isHighTextContrastEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether high text contrast is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when high text contrast is enabled and `false` otherwise. ```APIDOC ## `isHighTextContrastEnabled()` ### Description Query whether high text contrast is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when high text contrast is enabled and `false` otherwise. ### Signature static isHighTextContrastEnabled(): Promise ``` -------------------------------- ### Add React Native Subspecs to Podfile Source: https://reactnative.dev/docs/troubleshooting Include specific React Native subspecs like `RCTText`, `RCTImage`, `RCTNetwork`, and `RCTWebSocket` in your `Podfile` when using CocoaPods. ```ruby pod 'React', :path => '../node_modules/react-native', :subspecs => [ 'RCTText', 'RCTImage', 'RCTNetwork', 'RCTWebSocket', ] ``` -------------------------------- ### isReduceMotionEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether reduce motion is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when reduce motion is enabled and `false` otherwise. ```APIDOC ## `isReduceMotionEnabled()` ### Description Query whether reduce motion is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when reduce motion is enabled and `false` otherwise. ### Signature static isReduceMotionEnabled(): Promise; ``` -------------------------------- ### Terminate Process by PID Source: https://reactnative.dev/docs/troubleshooting After identifying the process ID (PID) using `lsof`, execute this command to forcefully terminate the process. ```bash kill -9 ``` -------------------------------- ### isInvertColorsEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether invert colors is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when invert colors is enabled and `false` otherwise. ```APIDOC ## `isInvertColorsEnabled()` ### Description Query whether invert colors is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when invert colors is enabled and `false` otherwise. ### Signature static isInvertColorsEnabled(): Promise; ``` -------------------------------- ### addEventListener() Source: https://reactnative.dev/docs/accessibilityinfo Adds an event handler to listen for changes in various accessibility states, such as screen reader status, bold text, grayscale, invert colors, reduce motion, reduce transparency, and accessibility service changes. ```APIDOC ## `addEventListener()` ### Description Adds an event handler to listen for changes in various accessibility states, such as screen reader status, bold text, grayscale, invert colors, reduce motion, reduce transparency, and accessibility service changes. ### Signature `static addEventListener(eventName: AccessibilityChangeEventName | AccessibilityAnnouncementEventName, handler: (event: AccessibilityChangeEvent | AccessibilityAnnouncementFinishedEvent) => void): EmitterSubscription;` ### Parameters - **eventName** (`AccessibilityChangeEventName | AccessibilityAnnouncementEventName`) - Required - The name of the accessibility event to listen for. Supported events include `accessibilityServiceChanged`, `announcementFinished`, `boldTextChanged`, `grayscaleChanged`, `invertColorsChanged`, `reduceMotionChanged`, `reduceTransparencyChanged`, and `screenReaderChanged`. - **handler** (`(event: AccessibilityChangeEvent | AccessibilityAnnouncementFinishedEvent) => void`) - Required - The callback function to be invoked when the specified event fires. The event object's structure depends on the `eventName`. ### Returns `EmitterSubscription` - An object that can be used to unsubscribe from the event. ``` -------------------------------- ### Load Platform-Specific Components with Platform.select in React Native Source: https://reactnative.dev/docs/platform-specific-code Dynamically load different component implementations for iOS and Android using `Platform.select` to ensure the correct platform-specific component is rendered. ```React TSX const Component = Platform.select({ ios: () => require('ComponentIOS'), android: () => require('ComponentAndroid'), })(); ; ``` -------------------------------- ### Find Process ID on Port 8081 Source: https://reactnative.dev/docs/troubleshooting Use this command to identify the process currently listening on port 8081, which is commonly used by the Metro bundler. ```bash sudo lsof -i :8081 ``` -------------------------------- ### Passing Array and Number Props to a Component Source: https://reactnative.dev/docs/intro-react Demonstrates passing an array and a number as props to a React component, wrapped in single curly braces within JSX. ```jsx ``` -------------------------------- ### Increase Inotify Watcher Limit on Linux Source: https://reactnative.dev/docs/troubleshooting Command to increase the maximum number of user watches for inotify on Linux, resolving ENOSPC errors. ```shell echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p ``` -------------------------------- ### Rendering a Simple Text Element with a React Component Source: https://reactnative.dev/docs/intro-react Shows a functional component that returns a Text element, demonstrating how to render static text content within a React Native application using JSX. ```React TSX const Cat = () => { return Hello, I am your cat!; }; ``` -------------------------------- ### isBoldTextEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether a bold text is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when bold text is enabled and `false` otherwise. ```APIDOC ## `isBoldTextEnabled()` ### Description Query whether a bold text is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when bold text is enabled and `false` otherwise. ### Signature static isBoldTextEnabled(): Promise: ``` -------------------------------- ### Query if darker system colors are enabled (iOS) Source: https://reactnative.dev/docs/accessibilityinfo Checks if the 'Darker System Colors' accessibility setting is currently active on iOS. Returns a promise that resolves to `true` if enabled, `false` otherwise. ```React TSX static isDarkerSystemColorsEnabled(): Promise ``` -------------------------------- ### isScreenReaderEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether a screen reader is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when a screen reader is enabled and `false` otherwise. ```APIDOC ## `isScreenReaderEnabled()` ### Description Query whether a screen reader is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when a screen reader is enabled and `false` otherwise. ### Signature static isScreenReaderEnabled(): Promise; ``` -------------------------------- ### isReduceTransparencyEnabled() Source: https://reactnative.dev/docs/accessibilityinfo Query whether reduce transparency is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when a reduce transparency is enabled and `false` otherwise. ```APIDOC ## `isReduceTransparencyEnabled()` ### Description Query whether reduce transparency is currently enabled. Returns a promise which resolves to a boolean. The result is `true` when a reduce transparency is enabled and `false` otherwise. ### Signature static isReduceTransparencyEnabled(): Promise; ``` -------------------------------- ### Importing a native-specific module in React TSX Source: https://reactnative.dev/docs/platform-specific-code Shows how to import a module that utilizes native-specific extensions without explicitly including the `.native` part in the import path. ```tsx import Container from './Container'; ``` -------------------------------- ### Fix NPM Locking Error Permissions Source: https://reactnative.dev/docs/troubleshooting Resolve `EACCES` errors during npm operations by changing ownership of npm directories to the current user. ```bash sudo chown -R $USER ~/.npm ``` ```bash sudo chown -R $USER /usr/local/lib/node_modules ``` -------------------------------- ### Announce text for accessibility with options (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Posts a string to be announced by the screen reader. On iOS, announcements can be queued behind existing speech using the `queue` option. ```React TSX static announceForAccessibilityWithOptions( announcement: string, options: {queue?: boolean}, ); ``` -------------------------------- ### Query if cross-fade transitions are preferred (iOS) Source: https://reactnative.dev/docs/accessibilityinfo Determines if 'Reduce Motion' and 'Prefer Cross-Fade Transitions' settings are enabled on iOS. Returns a promise resolving to `true` if cross-fade transitions are preferred. ```React TSX static prefersCrossFadeTransitions(): Promise; ``` -------------------------------- ### Defining an Empty Functional Component in React Source: https://reactnative.dev/docs/intro-react Illustrates the basic syntax for defining a functional component named Cat using an arrow function, serving as a blueprint for UI elements. ```React TSX const Cat = () => {}; ``` -------------------------------- ### Set Style Property Conditionally with Platform.OS in React Native Source: https://reactnative.dev/docs/platform-specific-code Use `Platform.OS` to apply different style values based on the operating system, such as setting a specific height for iOS versus Android. ```React TSX import {Platform, StyleSheet} from 'react-native'; const styles = StyleSheet.create({ height: Platform.OS === 'ios' ? 200 : 100, }); ``` -------------------------------- ### Apply Platform-Specific Styles with Platform.select in React Native Source: https://reactnative.dev/docs/platform-specific-code Utilize `Platform.select` to define an object of platform-specific styles, allowing different background colors for iOS, Android, and other platforms like web. ```React TSX import {Platform, StyleSheet} from 'react-native'; const styles = StyleSheet.create({ container: { flex: 1, ...Platform.select({ ios: { backgroundColor: 'red', }, android: { backgroundColor: 'green', }, default: { // other platforms, web for example backgroundColor: 'blue', }, }), }, }); ``` -------------------------------- ### Check if screen reader is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if a screen reader (like TalkBack) is currently active. ```React TSX static isScreenReaderEnabled(): Promise; ``` -------------------------------- ### Passing a JavaScript Object as a Prop in JSX Source: https://reactnative.dev/docs/intro-react Illustrates how to pass a JavaScript object as a prop in JSX, requiring double curly braces: one for the JSX expression and one for the object literal itself. ```jsx {{width: 200, height: 200}} ``` -------------------------------- ### Composing Components with React Fragments Source: https://reactnative.dev/docs/intro-react Render multiple `Cat` components within a `Cafe` component using React Fragments (`<>...`) to group adjacent JSX elements without adding an extra DOM node. ```React TSX const Cafe = () => { return ( <> ); }; ``` -------------------------------- ### Import Platform-Specific Component in React Native Source: https://reactnative.dev/docs/platform-specific-code Import a component using its base name; React Native automatically resolves to the correct platform-specific file (e.g., `BigButton.ios.js` or `BigButton.android.js`) at runtime. ```React TSX import BigButton from './BigButton'; ``` -------------------------------- ### Check if reduce transparency is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the reduce transparency accessibility setting is currently active. ```React TSX static isReduceTransparencyEnabled(): Promise; ``` -------------------------------- ### Check if high text contrast is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the high text contrast accessibility setting is currently active. ```React TSX static isHighTextContrastEnabled(): Promise ``` -------------------------------- ### Check if grayscale is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the grayscale accessibility setting is currently active. ```React TSX static isGrayscaleEnabled(): Promise; ``` -------------------------------- ### Check if any accessibility service is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Checks if any accessibility service, including TalkBack or third-party apps, is enabled. Use `isScreenReaderEnabled` to check only for TalkBack. ```React TSX static isAccessibilityServiceEnabled(): Promise; ``` -------------------------------- ### Add an event listener for accessibility changes Source: https://reactnative.dev/docs/accessibilityinfo Registers a handler for various accessibility events, such as screen reader state changes or announcement finishes. ```React TSX static addEventListener( eventName: AccessibilityChangeEventName | AccessibilityAnnouncementEventName, handler: ( event: AccessibilityChangeEvent | AccessibilityAnnouncementFinishedEvent, ) => void, ): EmitterSubscription; ``` -------------------------------- ### Importing React Native Text Component Source: https://reactnative.dev/docs/intro-react Imports the Text Core Component from the react-native library, essential for displaying text in a React Native application. ```React TSX import {Text} from 'react-native'; ``` -------------------------------- ### sendAccessibilityEvent(host: HostInstance, eventType: AccessibilityEventTypes) Source: https://reactnative.dev/docs/accessibilityinfo Imperatively trigger an accessibility event on a React component, like changing the focused element for a screen reader. ```APIDOC ## static sendAccessibilityEvent(host: HostInstance, eventType: AccessibilityEventTypes) ### Description Imperatively trigger an accessibility event on a React component, like changing the focused element for a screen reader. ### Method Name sendAccessibilityEvent ### Parameters #### Method Parameters - **host** (HostInstance) - Required - The component ref to send the event to. - **eventType** (AccessibilityEventTypes) - Required - One of `'click'` (Android only), `'focus'`, `'viewHoverEnter'` (Android only), or `'windowStateChange'` (Android only). ``` -------------------------------- ### Import Firebase after React Native Source: https://reactnative.dev/docs/troubleshooting Ensure Firebase is imported after React Native to prevent conflicts with WebSocket polyfills. ```javascript import Firebase from 'firebase'; ``` -------------------------------- ### Check if reduce motion is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the reduce motion accessibility setting is currently active. ```React TSX static isReduceMotionEnabled(): Promise; ``` -------------------------------- ### Check if invert colors is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the invert colors accessibility setting is currently active. ```React TSX static isInvertColorsEnabled(): Promise; ``` -------------------------------- ### Importing useState Hook in React TSX Source: https://reactnative.dev/docs/intro-react Import the `useState` Hook from React to enable state management within functional components. ```React TSX import {useState} from 'react'; ``` -------------------------------- ### Detect Android API Version with Platform.Version in React Native Source: https://reactnative.dev/docs/platform-specific-code Check the Android API version using `Platform.Version` to implement conditional logic based on the specific Android platform version, such as Nougat (API 25). ```React TSX import {Platform} from 'react-native'; if (Platform.Version === 25) { console.log('Running on Nougat!'); } ``` -------------------------------- ### Check if bold text is enabled (React TSX) Source: https://reactnative.dev/docs/accessibilityinfo Queries the system to determine if the bold text accessibility setting is currently active. ```React TSX static isBoldTextEnabled(): Promise: ``` -------------------------------- ### setAccessibilityFocus(reactTag: number) Source: https://reactnative.dev/docs/accessibilityinfo Set accessibility focus to a React component. On Android, this calls `UIManager.sendAccessibilityEvent` method with passed `reactTag` and `UIManager.AccessibilityEventTypes.typeViewFocused` arguments. Deprecated: Prefer using `sendAccessibilityEvent` with eventType `focus` instead. ```APIDOC ## static setAccessibilityFocus(reactTag: number) ### Description Set accessibility focus to a React component. On Android, this calls `UIManager.sendAccessibilityEvent` method with passed `reactTag` and `UIManager.AccessibilityEventTypes.typeViewFocused` arguments. Deprecated: Prefer using `sendAccessibilityEvent` with eventType `focus` instead. ### Method Name setAccessibilityFocus ### Parameters #### Method Parameters - **reactTag** (number) - Required - The React component tag to set focus on. ``` -------------------------------- ### Declaring State with useState in a React Component Source: https://reactnative.dev/docs/intro-react Declare a state variable `isHungry` and its setter `setIsHungry` within a functional component using `useState`, initializing `isHungry` to `true`. ```React TSX const Cat = (props: CatProps) => { const [isHungry, setIsHungry] = useState(true); // ... }; ``` -------------------------------- ### Updating State on Button Press in React Source: https://reactnative.dev/docs/intro-react Attach an `onPress` handler to a `Button` component to update the `isHungry` state variable to `false` when the button is pressed. ```React TSX