6

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"
}
});
1
  • 4
    I'm facing the same problem. Please post the answer if you were able to find a solution. Thanks. Commented May 17, 2019 at 9:04

2 Answers 2

-1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I did this.manager = new BleManager(); in componentDidMount() . But still it throws the error
-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.