5

I am new to React native framework. I have created app using 'create-react-native-app AwesomeProject'. I want to use BLE in my project so i installed the 'react-native-ble-plx' module but when i create the instance of BleManager it throws the error TypeError: Cannot read property 'createClient' of undefined. Why it throwing this error? My App.js is:

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"
}
});
pooja
  • 159
  • 1
  • 13

2 Answers2

-1

add this.manager = new BleManager(); in componentDidMount()

Anis D
  • 761
  • 11
  • 25
  • I did this.manager = new BleManager(); in componentDidMount() . But still it throws the error – pooja Sep 13 '18 at 05:32
-1

Inside your project folder, do:

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

Follow the instructions here: https://github.com/Polidea/react-native-ble-plx there is also a example project here: https://github.com/Cierpliwy/SensorTag

Maidenone
  • 723
  • 10
  • 22