react-native-macos/RNTester/js/utils
Janic Duplessis cc068b0551 Export the DevSettings module, add `addMenuItem` method (#25848)
Summary:
I wanted to configure the RN dev menu without having to write native code. This is pretty useful in a greenfield app since it avoids having to write a custom native module for both platforms (and might enable the feature for expo too).

This ended up a bit more involved than planned since callbacks can only be called once. I needed to convert the `DevSettings` module to a `NativeEventEmitter` and use events when buttons are clicked. This means creating a JS wrapper for it. Currently it does not export all methods, they can be added in follow ups as needed.

## Changelog

[General] [Added] - Export the DevSettings module, add `addMenuItem` method
Pull Request resolved: https://github.com/facebook/react-native/pull/25848

Test Plan:
Tested in an app using the following code.

```js
if (__DEV__) {
 DevSettings.addMenuItem('Show Dev Screen', () => {
    dispatchNavigationAction(
      NavigationActions.navigate({
        routeName: 'dev',
      }),
    );
  });
}
```

Added an example in RN tester

![devmenu](https://user-images.githubusercontent.com/2677334/62000297-71624680-b0a1-11e9-8403-bc95c4747f0c.gif)

Differential Revision: D17394916

Pulled By: cpojer

fbshipit-source-id: f9d2c548b09821c594189d1436a27b97cf5a5737
2019-09-17 06:38:10 -07:00
..
RNTesterActions.js useColorScheme hook (#26143) 2019-08-31 11:22:43 -07:00
RNTesterList.android.js Export the DevSettings module, add `addMenuItem` method (#25848) 2019-09-17 06:38:10 -07:00
RNTesterList.ios.js Export the DevSettings module, add `addMenuItem` method (#25848) 2019-09-17 06:38:10 -07:00
RNTesterNavigationReducer.js useColorScheme hook (#26143) 2019-08-31 11:22:43 -07:00
RNTesterStatePersister.js - Update folder structure of RNTester's JS directory. (#25013) 2019-05-28 08:39:18 -07:00
URIActionMap.js @allow-large-files Deploy Flow v0.99.0 to xplat/js 2019-05-29 18:11:43 -07:00