我在模拟器上不断崩溃,事件keyboardDidChangeFrame
RCTKeyboardObserver
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bridge is not set. This is probably because you've explicitly synthesized the bridge in RCTKeyboardObserver, even though it's inherited from RCTEventEmitter.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001145091ab __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000112a03f41 objc_exception_throw + 48
2 CoreFoundation 0x000000011450e372 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001124de523 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 165
4 Ology 0x000000010e4fef88 -[RCTEventEmitter sendEventWithName:body:] + 408
5 Ology 0x000000010e543544 -[RCTKeyboardObserver keyboardDidChangeFrame:] + 116
6 CoreFoundation 0x00000001144a4fdc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
7 CoreFoundation 0x00000001144a4eda _CFXRegistrationPost + 442
8 CoreFoundation 0x00000001144a4c22 ___CFXNotificationPost_block_invoke + 50
9 CoreFoundation 0x00000001144668c2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
10 CoreFoundation 0x0000000114465a3c _CFXNotificationPost + 652
11 Foundation 0x00000001123e5852 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
12 UIKit 0x0000000110dfa30c -[UIInputWindowController postEndNotifications:withInfo:] + 200
13 UIKit 0x0000000110dfcdeb __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke_2.1049 + 84
14 UIKit 0x0000000110df518f -[UIInputWindowController performWithSafeTransitionFrames:] + 174
15 UIKit 0x0000000110dfcca6 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1042 + 921
16 Foundation 0x000000011245a609 __NSFireDelayedPerform + 409
17 CoreFoundation 0x00000001144992a4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
18 CoreFoundation 0x0000000114498f62 __CFRunLoopDoTimer + 1026
19 CoreFoundation 0x0000000114498b1a __CFRunLoopDoTimers + 266
20 CoreFoundation 0x0000000114490534 __CFRunLoopRun + 2308
21 CoreFoundation 0x000000011448f9b9 CFRunLoopRunSpecific + 409
22 GraphicsServices 0x0000000119d6d9c6 GSEventRunModal + 62
23 UIKit 0x00000001101ac5e8 UIApplicationMain + 159
24 Ology 0x000000010e445e7f main + 111
25 libdyld.dylib 0x000000011a5e0d81 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我的环境是XCode 9.1(但我在以前的版本上也有这个)模拟器:iPhone 6s反应原生:0.49.x
包.json
{
"name": "Ology",
"version": "0.0.1",
"private": true,
"scripts": {
"test": "jest",
"start": "node node_modules/react-native/local-cli/cli.js start",
"flow": "flow",
"flow-stop": "node_modules/.bin/flow stop",
"translate": "babel app --plugins=react-intl",
"tmp": "react-intl-cra './app/**/*.js' './app/resources/message'",
"postinstall":
"sed -i '' 's/\[headers\[@"Content-Length"\] unsignedIntValue\]/\[headers\[@"Content-Length"\] intValue\]/' ./node_modules/react-native/React/Base/RCTMultipartStreamReader.m",
"eslint-check":
"eslint --print-config .eslintrc.js | eslint-config-prettier-check"
},
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [],
"snapshotSerializers": ["enzyme-to-json/serializer"],
"setupTestFrameworkScriptFile": "./test/setupJest.js",
"moduleDirectories": ["node_modules"],
"transform": {
"^.+\.jsx?$": "babel-jest"
}
},
"rnpm": {
"assets": ["app/styles/fonts"]
},
"resolutions": {
"react-native-material-kit":
"git+https://github.com/xinthink/react-native-material-kit.git"
},
"dependencies": {
"autobind-decorator": "^2.1.0",
"cheerio-without-node-native": "^0.20.2",
"diacritic": "0.0.2",
"expect": "^1.20.2",
"harmony-proxy": "^1.0.1",
"hoist-non-react-statics": "^2.3.1",
"immutable": "^3.8.1",
"jest-enzyme": "^4.0.1",
"lodash": "^4.17.4",
"lodash-es": "^4.17.4",
"lodash.debounce": "^4.0.8",
"lodash.memoize": "^4.1.2",
"lodash.mergewith": "^4.6.0",
"lodash.sorteduniq": "^4.2.0",
"lodash.sorteduniqby": "^4.7.0",
"lodash.throttle": "^4.1.1",
"lodash.union": "^4.6.0",
"lodash.unionwith": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"mime-types": "^2.1.17",
"moment": "^2.18.1",
"normalizr": "^3.2.3",
"normalizr-immutable": "0.0.4-beta12",
"path": "^0.12.7",
"react": "16.0.0-beta.5",
"react-immutable-proptypes": "^2.1.0",
"react-intl": "^2.4.0",
"react-intl-redux": "^0.6.0",
"react-native": "0.49.5",
"react-native-action-button": "^2.8.0",
"react-native-animatable": "^1.2.3",
"react-native-autolink": "^1.1.1",
"react-native-code-push": "5.1.3-beta",
"react-native-cookies": "^3.2.0",
"react-native-deprecated-custom-components": "^0.1.1",
"react-native-drawer": "^2.3.0",
"react-native-fetch-blob": "^0.10.8",
"react-native-fs": "^2.5.2",
"react-native-image-crop-picker": "^0.18.1",
"react-native-immutable-list-view": "^0.6.2",
"react-native-invertible-scroll-view": "^1.0.0",
"react-native-keyboard-aware-scroll-view": "^0.4.1",
"react-native-keychain": "2.0.0-rc",
"react-native-lightbox": "^0.7.0",
"react-native-linear-gradient": "^2.3.0",
"react-native-material-bottom-navigation": "^0.5.2",
"react-native-material-kit": "^0.4.1",
"react-native-modalbox": "^1.4.1",
"react-native-parallax-scroll-view": "^0.19.0",
"react-native-photo-view": "^1.5.2",
"react-native-popup-menu": "^0.8.0",
"react-native-progress": "^3.3.0",
"react-native-scrollable-tab-view": "^0.8.0",
"react-native-sglistview": "^0.4.3",
"react-native-store": "^0.4.1",
"react-native-swiper": "^1.5.13",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "1.0.0-beta.13",
"react-redux": "^5.0.5",
"react-swipeable-views": "^0.12.5",
"react-swipeable-views-native": "^0.12.5",
"realm": "^2.0.2",
"redux": "^3.7.2",
"redux-form": "^7.1.1",
"redux-logger": "^3.0.6",
"redux-middleware-oneshot": "^0.1.1",
"redux-persist": "^4.8.2",
"redux-persist-immutable": "^4.3.0",
"redux-persist-transform-immutable": "^4.3.0",
"redux-thunk": "^2.2.0",
"reselect": "^3.0.1",
"route-parser": "0.0.5",
"webstomp-client": "^1.0.8"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-plugin-module-resolver": "3.0.0-beta.5",
"babel-plugin-react-intl": "^2.3.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-preset-airbnb": "^2.4.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"babel-register": "^6.24.1",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"chai-enzyme": "^0.8.0",
"chai-immutable": "^1.6.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.7.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-react-native": "^3.1.0",
"eslint-plugin-standard": "^3.0.1",
"expect.js": "^0.3.1",
"flow": "^0.2.3",
"flow-bin": "^0.56.0",
"immutablediff": "^0.4.3",
"jest": "^21.2.1",
"jshint": "^2.9.5",
"mocha": "^3.4.2",
"react-addons-test-utils": "^15.6.2",
"react-dom": "16.0.0-beta.5",
"react-intl-cra": "^0.2.8",
"react-native-mock": "^0.3.1",
"react-test-renderer": "^16.0.0",
"redux-debounce": "^1.0.1",
"redux-debounced": "^0.4.0",
"redux-devtools": "^3.4.0",
"redux-devtools-dock-monitor": "^1.1.2",
"redux-devtools-log-monitor": "^1.3.0",
"redux-mock-store": "^1.2.3",
"regenerator-runtime": "^0.11.0",
"remote-redux-devtools": "^0.5.12",
"sinon": "^4.0.0"
}
}
有什么建议吗?
这只是一个愚蠢的错误。我像在网上一样实现它。
我是这样做的
componentDidMount() {
this.keyboardShowListener = Keyboard.addListener('keyboardDidShow', this.keyboardDidShow);
this.keyboardHidenListener = Keyboard.addListener('keyboardDidHide', this.keyboardDidHide);
}
componentWillUnmount() {
this.keyboardShowListener && this.keyboardShowListener.remove();
this.keyboardHidenListener && this.keyboardHidenListener.remove();
}
它应该是
componentDidMount() {
Keyboard.addListener('keyboardDidShow', this.keyboardDidShow);
Keyboard.addListener('keyboardDidHide', this.keyboardDidHide);
}
componentWillUnmount() {
Keyboard.removeListener('keyboardDidShow');
Keyboard.removeListener('keyboardDidHide');
}