Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HermanVulkers opened this issue Apr 14, 2022 · 10 comments

Comments

@HermanVulkers
Copy link

Hello everyone,

I am trying to use this checkbox in a NextJS + React Native Web app, but am receiving the following error when I try to insert the CheckBox code:

Server Error
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.

Source code:

pages/_document.tsx (19:23) @ Function.getInitialProps

  17 | AppRegistry.registerComponent(config.name, () => Main);
  18 | const { getStyleElement } = AppRegistry.getApplication(config.name);
> 19 | const page = await renderPage();
     |                   ^
  20 | const styles = [
  21 |   <style dangerouslySetInnerHTML={{ __html: normalizeNextElements }} />,
  22 |   getStyleElement(),

I have checked several things, such as my import:

import CheckBox from "@react-native-community/checkbox";

But this should be OK.

Does anyone have an idea what could be going wrong?

Thanks in advance!

@nicholaslee119
Copy link
Collaborator

Thanks for using this component. : )

I am wondering how did you know this issue was caused by the checkbox. Is there any possibility that another lib caused this issue? Because I can not reproduce this issue in my environment just only with the checkbox.

@nicholaslee119 nicholaslee119 added help wanted Extra attention is needed reproducing and removed help wanted Extra attention is needed labels Apr 25, 2022
@AndreLPD
Copy link

@nicholaslee119
I have the same error:

Server Error:

Uncaught 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 is my import:
import CheckBox from "@react-native-community/checkbox";

I used the State and HandleChange to receive the data:
state = { fluxo : false } handleChange = (event) => { console.log(event); }
<CheckBox disabled={false} value={this.state.fluxo} onValueChange={this.handleChange} />

@Itoukee
Copy link

Itoukee commented May 17, 2022

Hi, I have the exact same error. I checked my package, yarn lock and podfile but I don't have any possible conflicts with another checkbox. I know the checkbox is the issue because since I've installed it it crashes even without importing it !

React native version 0.67.4

@esien525
Copy link

image

@nicholaslee119 I have the same error.. it is working fine in Android emulator, however, no luck in RNW

@danielyaa5
Copy link

same

@Gobelin-Nounours
Copy link

Gobelin-Nounours commented Aug 17, 2022

same here. and i have verfiied, it's not another lib. i precise, it's in expo on web emulation, i will try in android view. and it's the same

@capic
Copy link

capic commented Sep 7, 2022

same

@professorplumb
Copy link

professorplumb commented Oct 12, 2022

Also have this same error on v0.5.12, react-native v0.69.6. Verified it's the imported CheckBox causing this error.

import CheckBox from '@react-native-community/checkbox';
...
<CheckBox />

If I console.log(CheckBox) in my function body (even if I just import the checkbox and don't actually use it) it comes back as undefined.

@apexskier
Copy link

It appears this package just isn't supported outside of ios, android, or windows. The primary source file (https://github.com/react-native-checkbox/react-native-checkbox/blob/develop/src/js/CheckBox.ts) on a web platform will circularly reference itself, as you can see in the final dist when you install the package.

ui — -bash — bash - Terminal - 2022-10-31 at 09 38 58@2x

@c9s
Copy link

c9s commented May 7, 2023

same here for the Web version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants