NativeModule.Defaults is null

I am trying to use the https://www.scandit.com/ SDK for a project with expo, I sent an email to the SDK company and they sent me the following code:

import React from 'react';
import { Alert } from 'react-native';
import {
  BarcodeCapture,
  BarcodeCaptureSettings,
  Symbology,
  SymbologyDescription,
} from 'scandit-react-native-datacapture-barcode';
import { Camera, DataCaptureContext, DataCaptureView, FrameSourceState } from 'scandit-react-native-datacapture-core';
export default function App() {
  this.viewRef = React.createRef();
  this.context = DataCaptureContext.forLicenseKey('-- ENTER YOUR SCANDIT LICENSE KEY HERE --');
  this.camera = Camera.default;
  this.context.setFrameSource(this.camera);
  this.camera.switchToDesiredState(FrameSourceState.On);
  const settings = new BarcodeCaptureSettings();
  settings.enableSymbologies([Symbology.EAN13UPCA, Symbology.QR, Symbology.Code39, Symbology.Code128]);
  this.barcodeCaptureMode = BarcodeCapture.forContext(this.context, settings);
  this.barcodeCaptureListener = {
    didScan: (_, session) => {
      const barcode = session.newlyRecognizedBarcodes[0];
      const symbology = new SymbologyDescription(barcode.symbology);
      this.barcodeCaptureMode.isEnabled = false;
      Alert.alert(
        null,
        `Scanned: ${barcode.data} (${symbology.readableName})`,
        [{ text: 'OK', onPress: () => this.barcodeCaptureMode.isEnabled = true }],
        { cancelable: false }
      );
    }
  };
  this.barcodeCaptureMode.addListener(this.barcodeCaptureListener);
  return (
    <DataCaptureView style={{ flex: 1 }} context={this.context} ref={this.viewRef} />
  );
}

starting it with expo gives me the following error:


how can i solve?
Thanks a lot

I have the same problem, any news?

I know this is old, but the reason this is happening is because scandit is a native module and has native code. You need to use custom dev client if you are using managed expo or eject from expo.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.