blue
blue

Reputation: 7375

React Native - "Element type is invalid: expected a string or a class/function but got undefined" - importing custom library?

Alright, I need to hack/tweak this library, so Im trying to import the not transpiled version by downloading the repo and importing: https://github.com/nicotroia/react-native-floating-action-menu#readme

All the paths are correct and the structure of the folder is:

enter image description here

When I do import { FloatingMenu } from './FloatingMenu/components/FloatingMenu'; I get the error:

Element type is invalid: expected a string or a class/function but got undefined

Says to "Check the render method of App." What is wrong here?

Upvotes: 1

Views: 44

Answers (1)

Nicholas Tower
Nicholas Tower

Reputation: 85012

Assuming the non-transpiled code you're using is this file, the issue is that it's got a default export, but you're using a named import, not a default import. The fix is to change this:

import { FloatingMenu } from './FloatingMenu/components/FloatingMenu';

To this:

import FloatingMenu from './FloatingMenu/components/FloatingMenu';

Upvotes: 2

Related Questions