简体   繁体   中英

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

Updated expo client and many issues were caused, but this one is all that is left. I can't find a solution that works for me for this supposedly common problem. I believe it could be sourced from the fact that the part of the code causing the error is modularised.

I have tried importing differently, exporting differently. I hoped that this would solve my issues but neither did.

Code to be imported:

export default class Timetable extends Component {
  constructor(props) {
    super(props);
    this.numberOfDays = 1;
    this.pivotDate = genTimeBlock(JSON.stringify(getDayOfWeek(getCurrentDate('-')), 0));
  }

  scrollViewRef = (ref) => {
    this.timetableRef = ref;
  };

  render() {
    return (
      <SafeAreaView style={{flex: 1}}>
        <View style = {styles.container}>
          <TimeTableView
            scrollViewRef={this.scrollViewRef}
            events={events_data}
            pivotTime={8}
            pivotEndTime={20}
            //pivotDate={this.pivotDate}
            locale = 'en'
            formatDateHeader = 'ddd'
            nDays={this.numberOfDays}
            headerStyle = {styles.headerStyle}
          />
        </View>
      </SafeAreaView>
      
    );
  }

Code for importing:

import {Timetable} from './SourceFiles/Timetable';

Code for calling the element:

function CalendarScreen({ navigation }) {
  return (
    <View style={{ flex: 1 }}>
      <Timetable />
      <FabButton nav={navigation} />
    </View>
  );

I found the answer I was importing a component that I was making use of from a library incorrectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question NextJS: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined Element type is invalid: expected string (for built-in components) or a class/function (for composite components) but got: undefined Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined Render Error Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined Console error: Element type is invalid:expected a string (for built-in components) or a class/function (for composite components) but got: undefined ReactDOM - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined React - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined error - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. in nextjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM