react-native-ui-lib icon indicating copy to clipboard operation
react-native-ui-lib copied to clipboard

Button Component is undefined

Open zh925 opened this issue 2 years ago • 9 comments

Description

I import Button and render it, has an 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.

Then I console.log(Button), it was an undefined in my logs.

Related to

  • [x] Components
  • [ ] Demo
  • [ ] Docs
  • [ ] Typings

Steps to reproduce

import { View, Button } from 'react-native-ui-lib'

export default function MyScreen() {
    return (
        <View>
            <Button label="click" />
        </View>
    )
}

Expected behavior

render the button

Actual behavior

throw an error

More Info

Code snippet

import { View, Button } from 'react-native-ui-lib'

export default function MyScreen() {
    return (
        <View>
            <Button label="click" />
        </View>
    )
}

Screenshots/Video

Environment

  • React Native version: 0.72.7
  • React Native UI Lib version: 7.12.0

it was same on [email protected]

Affected platforms

  • [x] Android
  • [ ] iOS
  • [ ] Web

zh925 avatar Dec 11 '23 07:12 zh925

I have the same problem on iOS

JacobWennebro avatar Jan 02 '24 21:01 JacobWennebro

~Same thing, an example from the documentation: https://wix.github.io/react-native-ui-lib/docs/getting-started/usage does not work. For View, Text and TextField it does, but fails on Button.~

upd.

To me it helped to make sure that react-native-reanimated is installed following this guide: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/

Specifically, run npx expo start -c afterwards

PavelPolyakov avatar Jan 04 '24 14:01 PavelPolyakov

Running into the same issue image

andrewvmail avatar Jan 09 '24 09:01 andrewvmail

I had the same problem,It's not just Button, there are other components that have this problem as well

zp342519261 avatar Jan 23 '24 02:01 zp342519261

I updated the libraries recommended by Expo, and it worked.

"dependencies": { "expo": "~50.0.6", "expo-status-bar": "~1.11.1", "react": "18.2.0", "react-native": "0.73.4", "react-native-calendars": "^1.1303.0", "react-native-gesture-handler": "~2.14.0", "react-native-reanimated": "~3.6.2", "react-native-ui-lib": "^7.16.0" }, "devDependencies": { "@babel/core": "^7.20.0" },

alvaromirandamita avatar Feb 11 '24 04:02 alvaromirandamita

same issue here

AymenObba avatar Feb 16 '24 15:02 AymenObba

I updated the libraries recommended by Expo, and it worked.

"dependencies": { "expo": "~50.0.6", "expo-status-bar": "~1.11.1", "react": "18.2.0", "react-native": "0.73.4", "react-native-calendars": "^1.1303.0", "react-native-gesture-handler": "~2.14.0", "react-native-reanimated": "~3.6.2", "react-native-ui-lib": "^7.16.0" }, "devDependencies": { "@babel/core": "^7.20.0" },

Updated libraries...Working!!

jami-yashwanth avatar Apr 10 '24 08:04 jami-yashwanth

did anyone came up with any solutions? dealing with the same issue when trying to use <TextField>

paulamurta avatar Jul 24 '24 15:07 paulamurta

I had to add react-native-reanimated Babel plugin to babel.config.js:

  module.exports = {
    presets: [
      ... // don't add it here :)
    ],
    plugins: [
      ...
      'react-native-reanimated/plugin',
    ],
  };

https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-2-add-reanimateds-babel-plugin

mateusz- avatar Oct 02 '24 01:10 mateusz-

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 31 '25 23:01 stale[bot]