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

fix: create symlink to common directory #2512

Merged
merged 3 commits into from
Oct 25, 2024
Merged

fix: create symlink to common directory #2512

merged 3 commits into from
Oct 25, 2024

Conversation

jakex7
Copy link
Member

@jakex7 jakex7 commented Oct 25, 2024

Summary

After changing project structure, local images stopped displaying on Android. This is due to the fact that React Native on Android uses okhttp for requests, which modifies the endpoint "by cleaning up the wrong part" from
http://10.0.2.2:8081/../common/example/assets/image.jpg
to
http://10.0.2.2:8081/common/example/assets/image.jpg

A quick fix for this is to create a symlink to the common directory, allowing images to be resolved without the ../ segment.

Special thanks to Kudo for sharing the original workaround here: facebook/metro#322 (comment).

@jakex7 jakex7 merged commit 8e865a9 into main Oct 25, 2024
1 check passed
@jakex7 jakex7 deleted the @jakex7/fixMetro branch October 25, 2024 17:59
github-merge-queue bot pushed a commit to software-mansion/react-native-reanimated that referenced this pull request Oct 28, 2024
## Summary

Similar to
software-mansion/react-native-svg#2512, it fixes
resolving local images on Android by creating a symlink to the common
directory, allowing images to be resolved without the `../` segment.

## Test plan

Run example app on Android and add
```tsx
<Image source={require('./assets/doge.png')} />
```
in `EmptyExample.tsx`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant