react native 踩坑記
react native 碰到的幾個坑。記錄如下。
1.com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'n.internals.offset[e]'), stack:
[email protected]:3247
[email protected]:2792
<unknown>@728:4023
<unknown>@23:1787
解決辦法:
更改檔案 node_modules/react-native-swiper/src/index.js 398 line add
if(offset === undefined || this.internals.offset === undefined){ return; }
———————————————————
2. react-native 除錯的時候會有報錯:日誌Attempted to transition from state `RESPONDER_INACTIVE_PRESS_IN` to `RESPONDER_ACTIVE_LONG_PRESS_IN`, which is not supported. This is most likely due to `Touchable.longPressDelayTimeout` not being cancelled.
reactConsoleErrorHandler @ ExceptionsManager.js:71
console.error @ YellowBox.js:61
_handleLongDelay @ Touchable.js:596
解決辦法:
My practical solution was to edit react-native source code at:
node-modules/react-native/Libraries/Components/Touchable/Touchable.js
Here I've changed "console.error" to "console.log" at line 628, this way I receive the message, however my app is not interrupted and the error is "dissmissed"
3.react native 類似安卓的viewpage 輪播圖片的時候,應用的控制元件有報錯,cannot read property x of undefined react native 。android 某些機型輪播無限滾動情況。
解決辦法:
node_modules/react-native-swiper/src/index.js 171 line add
更改為:autoplayTimeout: 3,
可以避免cannot read property x of undefined react native 這個報錯,但實際上並沒有完全解決有些機型比如魅族,速度超快無限輪播的情況。