React Native TypeError: Невозможно прочитать свойство 'createClient' из неопределенного - PullRequest
0 голосов
/ 12 сентября 2018

Я новичок в React родной рамки. Я создал приложение, используя 'create-реакции-native-приложение AwesomeProject'. Я хочу использовать BLE в своем проекте, поэтому я установил модуль «act-native-ble-plx », но когда я создаю экземпляр BleManager, он выдает ошибку TypeError: Невозможно прочитать свойство 'createClient' из неопределенного. Почему выкидывает эту ошибку? Мой App.js:

import React from "react";
import { StyleSheet, Button, Text, View, Alert } from "react-native";
import { BleManager } from 'react-native-ble-plx';
export default class App extends React.Component {

 constructor() {
    super();
    this.manager = new BleManager();
 }

 TestFunction() {   
    Alert.alert('Button Pressed !!!')   
 }

render() {
  return (
    <View style={styles.container}>
      <Button onPress={ this.TestFunction } title="Learn 
          More"color="#841584" /> 
    </View>
  );
  }
 } 

const styles = StyleSheet.create({
container: {
  flex: 1,
  backgroundColor: "#fff",
  alignItems: "center",
  justifyContent: "center"
}
});

Ответы [ 2 ]

0 голосов
/ 22 мая 2019

В папке вашего проекта выполните:

npm install --save react-native-ble-plx
react-native link react-native-ble-plx

Следуйте инструкциям здесь: https://github.com/Polidea/react-native-ble-plx здесь также есть пример проекта: https://github.com/Cierpliwy/SensorTag

0 голосов
/ 12 сентября 2018

добавить this.manager = new BleManager(); в componentDidMount ()

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...