mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 16:36:25 +00:00
Merge pull request #3717 from hswolff/android-native-modules-docs
Fix android native modules to reference right export
This commit is contained in:
commit
28687d83de
@ -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.
|
||||||
|
});
|
||||||
|
}
|
||||||
|
...
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user