react-native: index.js: The "id" argument must be of type string. Received undefined

Description

I’m moving the package and settings from React-Native 0.64.1 -> 0.69.3 and found out this error when running “npx react-native run-ios”.

Screenshot 2022-07-31 at 6 31 11 PM

Version

0.69.3

Output of npx react-native info

System: OS: macOS 12.2 CPU: (4) x64 Intel® Core™ i5-6267U CPU @ 2.90GHz Memory: 32.58 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.15.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.5.5 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.0 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 25, 26, 27, 28, 29, 30 Build Tools: 19.1.0, 20.0.0, 23.0.1, 23.0.3, 24.0.3, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.2, 29.0.3, 30.0.2 System Images: android-28 | Google Play Intel x86 Atom Android NDK: 14.1.3816874 IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 1.8.0_131 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.3 => 0.69.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

i create new module using “npx react-native init MyApp --template react-native-template-typescript” Then move the codes line by line from the file to file. (Including the package.json and podfile) And install the latest Xcode version.

I’m using the sample index.js and App.tsx. still get this error message.

I google through it and found none can help.

Please give some advice how to debug this.

Snack, code example, screenshot, or link to a repository

index.js

/**
 * @format
 */

import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => App);

App.tsx

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * Generated with the TypeScript template
 * https://github.com/react-native-community/react-native-template-typescript
 *
 * @format
 */

import React, {type PropsWithChildren} from 'react';
import {
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  useColorScheme,
  View,
} from 'react-native';

import {
  Colors,
  DebugInstructions,
  Header,
  LearnMoreLinks,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const Section: React.FC<
  PropsWithChildren<{
    title: string;
  }>
> = ({children, title}) => {
  const isDarkMode = useColorScheme() === 'dark';
  return (
    <View style={styles.sectionContainer}>
      <Text
        style={[
          styles.sectionTitle,
          {
            color: isDarkMode ? Colors.white : Colors.black,
          },
        ]}>
        {title}
      </Text>
      <Text
        style={[
          styles.sectionDescription,
          {
            color: isDarkMode ? Colors.light : Colors.dark,
          },
        ]}>
        {children}
      </Text>
    </View>
  );
};

const App = () => {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
      <ScrollView
        contentInsetAdjustmentBehavior="automatic"
        style={backgroundStyle}>
        <Header />
        <View
          style={{
            backgroundColor: isDarkMode ? Colors.black : Colors.white,
          }}>
          <Section title="Step One">
            Edit <Text style={styles.highlight}>App.tsx</Text> to change this
            screen and then come back to see your edits.
          </Section>
          <Section title="See Your Changes">
            <ReloadInstructions />
          </Section>
          <Section title="Debug">
            <DebugInstructions />
          </Section>
          <Section title="Learn More">
            Read the docs to discover what to do next:
          </Section>
          <LearnMoreLinks />
        </View>
      </ScrollView>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});

export default App;

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

not working for me after upgrading to 0.72

yarn add @react-native/metro-config@0.72.9 --dev

this worked

I had the same issue just now, the solution was removing “metro-config” from “dependencies”: {}. (not dev-dependencies)

Screenshot 2023-06-29 at 06 19 41

not working for me after upgrading to 0.72

Same here, also just upgraded to 0.72

after a disgusting hour of debugging i think an outdated metro version is the problem; while I can’t pin point why my repo is stuck on metro 0.76.8, forcing a resolution to 0.79.1 cleared this error.

Can also confirm that setting the @react-native/metro-config version explicitly to 0.72.9 (i e yarn add @react-native/metro-config0.72.9 --dev) fixed the issue for me (RN 0.72.2).

If you want to use react-native 0.72.1 on a monorepo like turbo i made a boilerplate for that enjoy it 😉

https://github.com/Morraycage/turbo-react-native-boilerplate

Still having the issue with:

RN: 0.72.6 Node: 18.18.2 @react-native/metro-config: 0.72.9

yarn add @react-native/metro-config@0.72.9 --dev

this worked

I had to upgrade my node version to the latest before this worked, but after that it solved the issue.

I have just migrated to 72.4 and started getting the same error. Downgrading @react-native/metro-config to 0.72.9 helped me.

With @react-native/metro-config 0.72.11 I get the following error when building the project:

TypeError: The "id" argument must be of type string. Received undefined error index.js: The "id" argument must be of type string. Received undefined

i have the same problem and i m stuck too

Anyone have any answers? Still stuck on this…

Ok, not sure how but i just fix myself accidentally.

i run codes as below

yarn add -D typescript @types/jest @types/react @types/react-native @types/react-test-renderer
yarn add --dev babel-plugin-module-resolver

And set the tsconfig.json

// prettier-ignore
{
  "extends": "@tsconfig/react-native/tsconfig.json",     /* Recommended React Native TSConfig base */
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "jsx": "react-native",
    "lib": ["es2017"],
    "moduleResolution": "node",
    "noEmit": true,
    "strict": true,
    "target": "esnext",
    "allowJs": true,
    "baseUrl": "src", /* Base directory to resolve non-absolute module names. */
    "paths": {
      "@src/*": [
        "*/index",
        "*"
      ]
    },
    /* Completeness */
    "skipLibCheck": true                                 /* Skip type checking all .d.ts files. */
  },
  "exclude": [
    "node_modules",
    "babel.config.js",
    "metro.config.js",
    "jest.config.js"
  ]
}