Merge pull request #3717 from hswolff/android-native-modules-docs

Fix android native modules to reference right export
This commit is contained in:
Martin Konicek 2015-10-27 14:36:50 +00:00
commit 28687d83de

View File

@ -229,7 +229,7 @@ sendEvent(reactContext, "keyboardWillShow", params);
JavaScript modules can then register to receive events by `addListenerOn` using the `Subscribable` mixin JavaScript modules can then register to receive events by `addListenerOn` using the `Subscribable` mixin
```js ```js
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var { DeviceEventEmitter } = require('react-native');
... ...
var ScrollResponderMixin = { var ScrollResponderMixin = {
@ -238,7 +238,7 @@ var ScrollResponderMixin = {
componentWillMount: function() { componentWillMount: function() {
... ...
this.addListenerOn(RCTDeviceEventEmitter, this.addListenerOn(DeviceEventEmitter,
'keyboardWillShow', 'keyboardWillShow',
this.scrollResponderKeyboardWillShow); this.scrollResponderKeyboardWillShow);
... ...
@ -248,3 +248,15 @@ var ScrollResponderMixin = {
this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e); this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e);
}, },
``` ```
You can also directly use the `DeviceEventEmitter` module to listen for events.
```js
...
componentWillMount: function() {
DeviceEventEmitter.addListener('keyboardWillShow', function(e: Event) {
// handle event.
});
}
...
```