question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing always returns undefined

See original GitHub issue

Hey there!

Firstly, thank you for creating and actively maintaining this package. I am very excited to use it!

Unfortunately, I am getting undefined whenever I try to import from react-native-bluetooth-classic.

Code ran

import RNBluetoothClassic, {
  BTEvents,
  BTCharsets,
} from 'react-native-bluetooth-classic';

const MyComponent = () => {
  console.log(RNBluetoothClassic.isEnabled());
  return (
    <View />
  );
};

Result

Unhandled JS Exception: TypeError: Cannot read property 'isEnabled' of undefined

Note that

  1. Importing the file directly from node_modules also yields the same error
  2. Directly console.logging RNBluetoothClassic, BTEvents, and BTCharsets all yield undefined
  3. Manually linking with Cocoapods yields the same error

Versions

Platform: iOS React native: 0.61.5 I also used yarn add instead of npm install, not sure if it makes a difference, but I can’t use npm install for other reasons.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kenjdavidsoncommented, Dec 30, 2020

It’s not in the readme, but it’s literally the second thing on the document page

https://www.kenjdavidson.com/react-native-bluetooth-classic/ios/#mfi-protocols

Oh, I see, you meant the second part

<key>NSBluetoothAlwaysUsageDescription</key>
	<string>Access bluetooth device over serial connection to document connection features</string>

I’ll add that now.

1reaction
hungdevcommented, Dec 30, 2020

thank for your asking, for who want to know what things we have to add:

	<key>UISupportedExternalAccessoryProtocols</key>
        <array>
          <string>com.apple.m1</string>
        </array>
	<key>NSBluetoothAlwaysUsageDescription</key>
	<string>Access bluetooth device over serial connection to document connection features</string>
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Redux this.props always return undefined
I'm now at React and I'm doing some apps to study, learn more about. Aand right now I'm trying to add the logged...
Read more >
Imports/requires return undefined #11562 - babel/babel - GitHub
I found out that happens when there is a _interopRequireDefault with a file inside the project which defers the resolving of modules or...
Read more >
Function returning 'undefined' - The freeCodeCamp Forum
My issue is when I import and use the function within a react function component the function suddenly only returns 'undefined'.
Read more >
Imported es6 module is undefined during Debug (During Test ...
Undefined variables while debugging must be caused by wrong/missing name mappings in sourcemaps: if the variable is renamed while transpiling/ ...
Read more >
All imported functions are undefined - Get Help - Vue Forum
All imported functions are undefined ... It always behaves the same way tho: ... console.log(get) // logs that it is a function
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found