TypeError:null不是对象(正在评估“ RNPalette.getNamedSwatches”)

时间:2020-10-15 23:17:53

标签: reactjs null

我的代码:

import React from "react";
import {getNamedSwatches} from 'react-native-palette';

import {
  StyleSheet,
  View,
  Platform,
  Image
} from "react-native";
import { Button } from 'react-native-paper';


export default function Capture({navigation}) {

 const imageUri = navigation.getParam('photo')
 calculateSome =()=> {
   console.log("im entering the function")
   if(Platform.OS==='android'){
    getNamedSwatches(imageUri, (error, swatches) => {
      if (error) {
        console.log(error);
      } else {
        swatches.sort((a, b) => {
          return b.population - a.population;
        });
        swatches.forEach((swatch) => {
          console.log(swatch.swatchInfo);
        });
      }
    });

   }
    
  }
 
   return (
    <View style={styles.wrapper}>
      <Image source={{ uri: imageUri.uri}} style={{width:380,height:550}}/>
      <View style={styles.captureButton}>
      <Button mode="outlined" onPress={calculateSome}>
        Proceed
      </Button>
      </View>
    </View>
  );
}

输出:

TypeError:null不是一个对象(正在评估“ RNPalette.getNamedSwatches”)

    registerError中的
  • node_modules \ react-native \ Libraries \ LogBox \ LogBox.js:148:8
  • nodeImodules \ react-native \ Libraries \ LogBox \ LogBox.js:59:8在errorImpl中
  • console.error中的node_modules \ react-native \ Libraries \ LogBox \ LogBox.js:33:4
  • node_modules \ expo \ build \ environment \ react-native-logs.fx.js:27:4错误
  • reportException中的node_modules \ react-native \ Libraries \ Core \ ExceptionsManager.js:104:6
  • nodeException中的
  • node_modules \ react-native \ Libraries \ Core \ ExceptionsManager.js:171:19
  • nodeError中的
  • node_modules \ react-native \ Libraries \ Core \ setUpErrorHandling.js:24:6
  • ErrorUtils.setGlobalHandler $ argument_0中的 node_modules \ expo-error-recovery \ build \ ErrorRecovery.fx.js:9:32
  • tryCatch中的
  • node_modules \ regenerator-runtime \ runtime.js:63:36
  • 调用
  • node_modules \ regenerator-runtime \ runtime.js:293:29
  • tryCatch中的
  • node_modules \ regenerator-runtime \ runtime.js:63:36
  • 调用
  • node_modules \ regenerator-runtime \ runtime.js:154:27
  • PromiseImpl.resolve.then $ argument_0中的
  • node_modules \ regenerator-runtime \ runtime.js:164:18
  • tryCallOne中的
  • node_modules \ react-native \ node_modules \ promise \ setimmediate \ core.js:37:13
  • setImmediate $ argument_0中的
  • node_modules \ react-native \ node_modules \ promise \ setimmediate \ core.js:123:24
  • _callTimer中的node_modules \ react-native \ Libraries \ Core \ Timers \ JSTimers.js:130:14
  • _callImmediatesPass中的
  • node_modules \ react-native \ Libraries \ Core \ Timers \ JSTimers.js:181:14
  • callImmediates中的node_modules \ react-native \ Libraries \ Core \ Timers \ JSTimers.js:441:30
  • __callImmediates中的
  • node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:387:6
  • __guard $ argument_0中的
  • node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:135:6
  • __guard中的
  • node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:36 enter code here 4:10
  • flushedQueue中的node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:134:4
  • [本地代码]:flushedQueue中为空
  • [本地代码]:invokeCallbackAndReturnFlushedQueue中为空

0 个答案:

没有答案