mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
74cb441e97
Summary: The documentation for `useColorScheme()` suggested that the user's preferred color scheme will be 'Dark Mode'. Instead suggesting 'Dark Mode' as an example of what the user's preferred color scheme could be is more correct. ## Changelog [INTERNAL] [FIXED] - Edited documentation for `useColorScheme()` hook Edited ```javascript /** * A new useColorScheme hook is provided as the preferred way of accessing * the user's preferred color scheme (aka Dark Mode). */ export function useColorScheme(): ColorSchemeName; ``` to ```javascript /** * A new useColorScheme hook is provided as the preferred way of accessing * the user's preferred color scheme (e.g. Dark Mode). */ export function useColorScheme(): ColorSchemeName; ``` Pull Request resolved: https://github.com/facebook/react-native/pull/35141 Test Plan: Documentation only - no testing required. Reviewed By: cipolleschi Differential Revision: D40934781 Pulled By: rshest fbshipit-source-id: acac8947c3f99016839be27f505066e8992a20fa
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {NativeEventSubscription} from '../EventEmitter/RCTNativeAppEventEmitter';
|
|
|
|
type ColorSchemeName = 'light' | 'dark' | null | undefined;
|
|
|
|
export namespace Appearance {
|
|
type AppearancePreferences = {
|
|
colorScheme: ColorSchemeName;
|
|
};
|
|
|
|
type AppearanceListener = (preferences: AppearancePreferences) => void;
|
|
|
|
/**
|
|
* Note: Although color scheme is available immediately, it may change at any
|
|
* time. Any rendering logic or styles that depend on this should try to call
|
|
* this function on every render, rather than caching the value (for example,
|
|
* using inline styles rather than setting a value in a `StyleSheet`).
|
|
*
|
|
* Example: `const colorScheme = Appearance.getColorScheme();`
|
|
*/
|
|
export function getColorScheme(): ColorSchemeName;
|
|
|
|
/**
|
|
* Add an event handler that is fired when appearance preferences change.
|
|
*/
|
|
export function addChangeListener(
|
|
listener: AppearanceListener,
|
|
): NativeEventSubscription;
|
|
}
|
|
|
|
/**
|
|
* A new useColorScheme hook is provided as the preferred way of accessing
|
|
* the user's preferred color scheme (e.g. Dark Mode).
|
|
*/
|
|
export function useColorScheme(): ColorSchemeName;
|