0

I am a beginner in react-native world!

I have seen many tutorials on react-native. In all the tutorials they say that we should run this command to create a new app called myApp:

react-native init myApp

So, I have done the same thing. Now, when I see the files that are automatically generated, I see a difference between tutorials and my code.

In my code, I get an index.js file.

But the tutorials that I follow, I can see index.android.js and index.ios.js files.

I also want to have these two different files as I will develop different UI's for Android and iOS.

5
  • 1
    Just create them. You can create any component later with this pattern xxxx.ios.js xxx.android.js and they will load base on platform. Commented Nov 1, 2017 at 9:16
  • @TarasDanylyuk so, you mean that I can create a common application for both platforms and then if I need a screen different on both platform, that time I should just create a copy of that component and just rename both files to xxx.android.js and xxx.ios.js and that's it!! Commented Nov 1, 2017 at 9:27
  • @TarasDanylyuk If I am getting it wrong then can you please explain it with a small example? Commented Nov 1, 2017 at 9:30
  • Yes you can have same file for both platform, but if you want to have different buttons on each platform, you just create Button.ios.js and Button.android.js. Then when importing this component you are using import Button from './Button' and you will have them different on each platform. Consider reading official docs: facebook.github.io/react-native/docs/… Commented Nov 1, 2017 at 9:33
  • @Thanks Now, I got it clear. Commented Nov 1, 2017 at 9:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.