Reputation: 34103
I use react-native-web
and share code between ios
, android
and web
.
Is there any technique to target both iOS and Android platform with a single file, and at the same time not target web
?
I know that the code below doesn't work, but serves as an example of what I have in mind:
Container.native.js
Container.web.js
Upvotes: 1
Views: 356
Reputation: 3184
It's very easy. For the same example you have given, this is how you can do it:
Container.js // For mobile
Container.web.js // For Web
Also, you can always use Platform.OS
for specific Platform specifications.
Hope it helps.
Upvotes: 1
Reputation: 881
so there two ways of having platform specific code in React Native as mentioned here. The method that you are referring to is mentioned here.
Remember that react-native-web
is designed firstly to make react native code run on the web, so your designing Mobile first.
Upvotes: 1