timothymiller / t4-app

A powerful cross-platform UI toolkit for building actually native iOS, Android, macOS, Windows, Linux, and Progressive Web Apps with React (Native).
https://t4stack.com
MIT License
1.31k stars 69 forks source link

Images not working with expo due to solito-image #115

Closed guioum closed 7 months ago

guioum commented 7 months ago

No images when running expo.

In solito-image, index.tsx uses:

process.env.NEXT_PUBLIC_APP_URL, but it's not available in expo.

Replacing this with process.env.EXPO_PUBLIC_APP_URL solves it.

export const getImageUrl = () => {
  const imageUrl = `${process.env.NEXT_PUBLIC_APP_URL}`
  return replaceLocalhost(imageUrl)
}
timothymiller commented 7 months ago

The framework takes care of generating the required prefix for Expo and Nextjs during install time.

All that's required is to define PUBLIC_ once, and the bun install postinstall runs a script to move the env vars into where they need to be.

guioum commented 7 months ago

Thanks, I just did what you said. I did a bun install then checked the generated .env.local in apps/expo but all generated variables start with the EXPO_ prefix. Thus, when getImageUrl (executed from expo) tries to get process.env.NEXT_PUBLIC_APP_URL, it doesn't exist.

(I use two terminals, one for bun dev, one for bun ios to run in the simulator)

timothymiller commented 7 months ago

Hmm you may have a point there. We need a flag for the expo environment and decide the var based on that. I'll do some investigating.

Thanks for calling this out!

timothymiller commented 7 months ago

Fixed this issue in the latest push. We have separate providers for Expo and Next.js, so no env flag required!