TypeError:Undefined不是对象密钥库

问题描述 投票:0回答:1

我只想在我的React Native项目中添加一个RNSecureKeystore,但我总是收到错误消息:“TypeError:undefined不是一个对象(评估_reactNativeSecureKeystore.default.set')”。错误位于DrawerNavScreen。

这可能是React Native版本的问题吗?

   import React, {Component} from 'react';
import {TextInput, TouchableHighlight, Modal, Button, Platform, StyleSheet, Text, View, Image} from 'react-native';
import {createStackNavigator, createDrawerNavigator} from 'react-navigation';
import RNSecureKeyStore, {ACCESSIBLE} from "react-native-secure-key-store";

   render(){

// For storing key
RNSecureKeyStore.set("key1", "value1", {accessible: ACCESSIBLE.WHEN_UNLOCKED})
  .then((res) => {
    console.log(res);
  }, (err) => {
    console.log(err);
  });

// For retrieving key 
RNSecureKeyStore.get("key1")
  .then((res) => {
    console.log(res);
  }, (err) => {
    console.log(err);
  });

// For removing key 
RNSecureKeyStore.remove("key1")
  .then((res) => {
    console.log(res);
  }, (err) => {
    console.log(err);
  });   
reactjs react-native typeerror storing-data
1个回答
0
投票

看起来你的应用程序中没有RNSecureKeyStore。您是否已将这些库成功链接在一起? react-native-link应该这样做,否则它可能与你正在使用的RN版本有关。

© www.soinside.com 2019 - 2024. All rights reserved.