aws-amplify / amplify-ui

Amplify UI is a collection of accessible, themeable, performant React (and more!) components that can connect directly to the cloud.
https://ui.docs.amplify.aws
Apache License 2.0
811 stars 271 forks source link

React Native Expo build failing with `withAuthenticator` #2841

Closed fergusmeiklejohn closed 1 year ago

fergusmeiklejohn commented 1 year ago

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React Native

Which UI component?

Authenticator

How is your app built?

Expo

What browsers are you seeing the problem on?

No response

Please describe your bug.

withAuthenticator is breaking the build: Unable to resolve "@react-native-picker/picker" from "node_modules/aws-amplify-react-native/dist/AmplifyUI.js"

What's the expected behaviour?

I expect this to work with an Expo/Typescript project

Help us reproduce the bug!

This is a simple repo: https://github.com/fergusmeiklejohn/WhatsApp

Build steps in the readme. I've committed when it builds and then a new commit for when the build fails.

Relevant file is App.tsx: line 30 export default withAuthenticator(App); With the export wrapped in withAuthenticator the build fails with this error: Unable to resolve "@react-native-picker/picker" from "node_modules/aws-amplify-react-native/dist/AmplifyUI.js"

Code Snippet

// Put your code below this line.

Additional information and screenshots

No response

calebpollman commented 1 year ago

Hi @fergusmeiklejohn Looking at the dependencies in your package.json, it looks like you are missing the "@react-native-picker/picker" dependency in your project. Can you please install it and run npx pod-install to see if that clears up your issue?

fergusmeiklejohn commented 1 year ago

Hi @calebpollman thanks for getting on this so fast, @react-native-picker/picker is a peer dependency of aws-amplify-react-native. But it wasn't installed with aws-amplify-react-native npx expo install @react-native-picker/picker installs it and fixes the error, I wonder why it wasn't installed with aws-amplify-react-native?

CleanShot 2022-10-29 at 09 55 04@2x
calebpollman commented 1 year ago

@fergusmeiklejohn pod install only links native code for dependencies listed in the parent project's dependencies field in the package.json (see this RFC for more info)