user6377312
user6377312

Reputation:

React Native Expo - Can I write code for both - IOS and Android with Expo or why does boilerplate code has only separate code?

Im just trying to figure out both react native and expo and wonder:

When I init a new project with expo, Im being directed to choosing a template. I can choose between the bare minimum and one that has more boilerplate code plus enabled typescript called "tabs". The boilerplate code for tabs has NO seperate code for IOS/android while the minimum temlate has code specifically for android and for ios so as I understand you must write everything double.

Why is it so different among these templates?!

Reading the react native docs: it says that there can be same code for both ios/android plus the use of Platform module/ platform-specific file extensions for cases where the code must differ. however as I understand it, its not the default.

Could someone explain to me why the expo minimum template suggests to write double code, having those 2 folders IOS and Android?!

enter image description here

Upvotes: 1

Views: 1003

Answers (1)

Nima Zarei
Nima Zarei

Reputation: 1228

You are not going to write the same code twice. React Native is all about writing in JavaScript. Even when you initialize your project with React Native CLI and not Expo you get those android and ios folders but you only code in your .js files. Of course, you can go further and edit those files and folders if you are familiar with mobile development since some functionalities (and React Native components) are only exclusive to one platform.

React components wrap existing native code and interact with native APIs via React’s declarative UI paradigm and JavaScript.

You can learn more about it here: https://reactnative.dev/

Upvotes: 2

Related Questions