Skip to content

Commit 2f6f8f5

Browse files
committed
fix RN 27 deprecation warning of DeviceEventEmitter for keyboard events (related to PR wix-incubator#8).
maintains backwards compatibility.
1 parent 4893ba7 commit 2f6f8f5

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"start": "react-native start"
77
},
88
"dependencies": {
9-
"react-native": "0.25.1",
10-
"react": "0.14.5",
9+
"react-native": "0.27.2",
10+
"react": "15.1.0",
1111
"react-native-keyboard-aware-scrollview": "latest"
1212
}
1313
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "git",
88
"url": "https://github.com/wix/react-native-keyboard-aware-scrollview.git"
99
},
10-
"version": "1.0.3",
10+
"version": "1.1.0",
1111
"description": "React Native Keyboard Aware ScrollView - auto adjust content ScrollView",
1212
"nativePackage": true,
1313
"bugs": {

src/KeyboardAwareBase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React , { Component, PropTypes } from 'react';
33

44
import ReactNative, {
55
DeviceEventEmitter,
6+
Keyboard,
67
NativeModules
78
} from 'react-native';
89

@@ -22,9 +23,10 @@ export default class KeyboardAwareBase extends Component {
2223
}
2324

2425
_addKeyboardEventListeners() {
26+
const KeyboardEventsObj = Keyboard || DeviceEventEmitter;
2527
this.keyboardEventListeners = [
26-
DeviceEventEmitter.addListener('keyboardWillShow', this._onKeyboardWillShow),
27-
DeviceEventEmitter.addListener('keyboardWillHide', this._onKeyboardWillHide)
28+
KeyboardEventsObj.addListener('keyboardWillShow', this._onKeyboardWillShow),
29+
KeyboardEventsObj.addListener('keyboardWillHide', this._onKeyboardWillHide)
2830
];
2931
}
3032

0 commit comments

Comments
 (0)