question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with platform-specific React Native files

See original GitHub issue

Hey!

I was running this on my React Native project, and I noticed that it wasn’t able to follow an import such as ./User and resolve it to ./User.ios.tsx and ./User.android.tsx.

I realise this is an edge-case and might be difficult to solve since IIRC these special extensions are handled by Metro. Just wanted to surface this in case anyone else has the same issue. Luckily I have very few platform-specific files so this tool is still super valuable.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
smeijercommented, Aug 7, 2021

Sorry, even though I had a working version, it took me a while to commit. Mostly because I didn’t really like the solution.

I believe I’ve now found a better way to support this, and the commit has been pushed. It’s way more generic, and adds support for build configs like react native, but also other projects that have multiple build targets.

I’ll release this soon. All that’s left is add some presets / auto detection so that you don’t need to setup complicated unimportedrc config files.

1reaction
dkartercommented, May 13, 2021

@smeijer Thank you so much for looking into this! This feature would be super useful for React Native. If you need any help I’m happy to lend a second pair of eyes!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flow doesn't recognize platform-specific react-native files #945
I still see an issue here: how can flow validate all files? I mean flow might want to choose .ios.js first, but this...
Read more >
Platform Specific Code - React Native
React Native provides two ways to organize your code and separate it by platform: Using the Platform module. Using platform-specific file ...
Read more >
How to use react native's platform-specific extensions with ...
The problem: I have a react native custom hook with platform specific code, which I need to import based on the platform.
Read more >
5 Most Common React Native Issues That Starters Face
Below Are Some React Native Issues that starters face · 1. App Registry Error in React Native: · 2. Development Server Error in...
Read more >
Why did I move from native platforms to React Native?
The development team needed to maintain three separate codebases despite having introduced cross-platform development. · The app required ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found