React Native安装包

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

React-Native新手在这里遇到问题,并想知道我是否错过了安装包的基本步骤。

我一直在尝试使用react-native-rsa-native软件包(https://github.com/amitaymolko/react-native-rsa-native

但是我得到了

TypeError: undefined is not an object (evaluating '_reactNativeRsaNative.RSA.generateKeys')

我的测试代码是:

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { RSA, RSAKeychain } from 'react-native-rsa-native';

export default class App extends React.Component {

  componentWillMount() {
    RSA.generateKeys(4096) // set key size
      .then(keys => {
        console.log('4096 private:', keys.private) // the private key
        console.log('4096 public:', keys.public) // the public key
      });
  }

  render() {
    ...
  }
}

接下来的步骤是:

expo init rsatest --template blank@sdk-31 --yarn
cd rsatest
yarn add react-native-rsa-native
react-native link react-native-rsa-native
yarn start

react-native-rsa-native包确实出现在node_modules目录中,但我觉得我遗漏了一些东西。

有任何想法吗?

react-native package
3个回答
1
投票

可能相关的一件事是不推荐使用componentWillMount。

https://reactjs.org/docs/react-component.html React docs是反应原生文档的基础。

还有componentWillMount()如果有fetch调用,带有promise,promise将不会在组件mount之前返回,组件将至少返回一次为空。

我建议尝试componentDidMount()

希望这可以帮助

编辑拼写*


0
投票

该图书馆与世博会不兼容。检查原因:react native link using expo?

所以你可能想要expo eject。我认为这也不是一种选择。

你怎么样在下面尝试这个呢? https://github.com/z-hao-wang/react-native-rsa


0
投票

您可以删除节点模块,然后npm install react-native link react-native run-android / run-ios

也许

这有用:qazxsw poi

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