react-native 报错解决

  1. BatchedBridge error in React Native on iOS

    将index.js文件改成index.ios.js

  2. Unable to resolve module react-navigation-stack

    $ npm install –save react-navigation-stack @react-native-community/masked-view react-native-safe-area-context

  3. TypeError: null is not an object (evaluating ‘_RNGestureHandlerModule.default.Direction’)

    pod文件里添加:

    1
    pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
  4. TypeError: undefined is not an object (evaluating ‘Object.keys(routeConfigs)’)

    import RouteConfig from ‘../RouteConfig’;

    引入类名 不带{}

    注意:在其他js中引用default导出的导出的函数类时,应为import 类名 from “./…js”,错误的写法是import { 类名} from “./…js”;

  5. Invariant Violation: requireNativeComponent: “RNCSafeAreaView” was not found in the UIManager.

    1
    2
    3
    4
    5
    6
    $ npm install --save react-native-safe-area-context
    $ npm install --save react-native-safe-area-view
    $ react-native link react-native-safe-area-view
    $ react-native link react-native-safe-area-context
    $cd ios
    $pod install
  6. SyntaxError: Identifier directly after number (70:15)

    rn里的css 是没有单位的

  7. TypeError: undefined is not an object (evaluating ‘this.state.page’) 在方法上加上bind(this)

    1
    <ScrollView onMomentumScrollEnd={this.contentViewScroll.bind(this)}>
  8. does not conform to the RCTBridgeModule protocol

    在oc @interface rctJobViewController () 加上后面的引用