cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynatrace React Native plugin fails with “Cannot call a class as a function” after upgrading to React Native 0.81

theahmadsami
Newcomer_

Hi all,

I recently upgraded my project from React Native 0.72.2 to React Native 0.81.0.

With RN 0.72.2 the Dynatrace React Native plugin worked fine, but after upgrading, the app crashes immediately on startup with the following error:

Error:

Render Error
Cannot call a class as a function

Source (Touchables.js:45:23):

exports.Text = (_d = class Text extends ReactNative.Text {
  },
  _d._dtInfo = { type: Types_1.Types.Text },
  _d);

Component Stack:

<Text />                Touchables.js:45
<AppText />             AppText.tsx:13
<ScrollView />          ScrollView.js:730
<ErrorFallback />       ProvidersWrapper.tsx:74
<ErrorBoundary />       react-error-boundary.js:11
<SafeAreaProvider />    SafeAreaContext.tsx:35
<Provider />            react-redux.legacy-esm.js:910
<View_withRef />        View.js:28
...

 

babel.config.js

module.exports = {
  presets: ['module:@react-native/babel-preset'],
  plugins: [
    [
      '@babel/plugin-transform-react-jsx',
      {
        runtime: 'automatic',
        importSource: '@dynatrace/react-native-plugin',
      },
    ],
    ['react-native-reanimated/plugin'],
  ],
};

 

metro.config.js

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const config = {
  transformer: {
    babelTransformerPath: require.resolve(
      '@dynatrace/react-native-plugin/lib/dynatrace-transformer',
    ),
  },
  reporter: require('@dynatrace/react-native-plugin/lib/dynatrace-reporter'),
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

 

dynatrace.config.js

module.exports = {
  react: {
    debug: true,
    autoStart: false,
    errorHandler: {
      enabled: true,
      reportFatalErrorAsCrash: true,
    },
    lifecycle: {
      includeUpdate: false,
      instrument: filename => false,
    },
    input: {
      instrument: filename => true,
    },
  },
  capture: { networkRequests: true },
  android: {
    enabled: true,
    config: `
      dynatrace {
        configurations {
          defaultConfig {
            autoStart.enabled false
          }
        }
      }
    `,
  },
  ios: {
    enabled: true,
    config: `
      <key>DTXAutoStart</key>
      <false/>
    `,
  },
};

 

1 REPLY 1

matthias_hochri
Dynatrace Pro
Dynatrace Pro

Hi,

We are aware of the issue. Solution is internally already working and will be released ASAP.

RN 0.81 changed the Text which is breaking the instrumentation for those parts.

Featured Posts