mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
[react-native] Add module DevSettings (#43679)
* feat: add dev settings to react-native * test: add test calls for dev settings * fix: remove trailing whitespace
This commit is contained in:
23
types/react-native/index.d.ts
vendored
23
types/react-native/index.d.ts
vendored
@@ -35,6 +35,7 @@
|
||||
// Mohamed Shaban <https://github.com/drmas>
|
||||
// André Krüger <https://github.com/akrger>
|
||||
// Jérémy Barbet <https://github.com/jeremybarbet>
|
||||
// Christian Ost <https://github.com/ca057>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -8913,6 +8914,28 @@ export interface KeyboardStatic extends NativeEventEmitter {
|
||||
addListener(eventType: KeyboardEventName, listener: KeyboardEventListener): EmitterSubscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* The DevSettings module exposes methods for customizing settings for developers in development.
|
||||
*/
|
||||
export interface DevSettingsStatic extends NativeEventEmitter {
|
||||
/**
|
||||
* Adds a custom menu item to the developer menu.
|
||||
*
|
||||
* @param title - The title of the menu item. Is internally used as id and should therefore be unique.
|
||||
* @param handler - The callback invoked when pressing the menu item.
|
||||
*/
|
||||
addMenuItem(title: string, handler: () => any): void;
|
||||
|
||||
/**
|
||||
* Reload the application.
|
||||
*
|
||||
* @param reason
|
||||
*/
|
||||
reload(reason?: string): void;
|
||||
}
|
||||
|
||||
export const DevSettings: DevSettingsStatic;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// R E - E X P O R T S
|
||||
|
||||
@@ -96,6 +96,7 @@ import {
|
||||
HostComponent,
|
||||
Appearance,
|
||||
useColorScheme,
|
||||
DevSettings,
|
||||
} from 'react-native';
|
||||
|
||||
declare module 'react-native' {
|
||||
@@ -1085,3 +1086,10 @@ const DarkMode = () => {
|
||||
|
||||
return <Text>Is dark mode enabled? {isDarkMode}</Text>;
|
||||
};
|
||||
|
||||
// DevSettings
|
||||
DevSettings.addMenuItem('alert', () => {
|
||||
Alert.alert('alert');
|
||||
});
|
||||
DevSettings.reload();
|
||||
DevSettings.reload('reload with reason');
|
||||
|
||||
Reference in New Issue
Block a user