Element type is invalid: expected a string (for built-in components) or a class/function but got: undefined

11 Views Asked by At

I'm getting below error while trying to dynamically import a storybook root component.

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

This error is located at:
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in ComposableHub(RootComponent), js engine: hermes

App.tsx

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Config from 'react-native-config';

function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.tsx to start working on your app!</Text>
    </View>
  );
}

let AppEntryPoint = App;

if (Config.STORYBOOK_ENABLED) {
  AppEntryPoint = require('./.ondevice').default;
}

export default AppEntryPoint;

./ondevice/index.tsx -

import { view } from "./storybook.requires";
import AsyncStorage from "@react-native-async-storage/async-storage";

const StorybookUIRoot = view.getStorybookUI({
  storage: {
    getItem: AsyncStorage.getItem,
    setItem: AsyncStorage.setItem,
  },
});

export default StorybookUIRoot;

Please let me know if I forgot to add any code or config. Thank you.

0

There are 0 best solutions below