user7691120
user7691120

Reputation:

How to code for React Native apps using Sublime

I am new to React Native. I could not find any set up guide to code for React Native apps using Sublime. How can I create a React Native project in Sublime?

I installed these components from tutorial and followed these guides, but when I tried to build from sublime, nothing has happened.

Any one mind to enlighten me? I know this is not a right place to ask but I could not think of any others and I am seriously stuck.

enter image description here

Upvotes: 1

Views: 2432

Answers (1)

Sivajee Battina
Sivajee Battina

Reputation: 4174

You can't directly run from sublime. Sublime is a TextEditor that you can use to change your react-native code. But to run the application you need to run the respective project in their respective IDEs. For an example, if you want to run it for iOS, you need to open your project in Xcode and run for the first time. Once it's launched by Xcode and simulator, then you can start coding in react-native in Sublime text editor and Command+R to reflect those changes here.

You can see index.ios.js file which is entry point for iOS code and you can create index.android.js file which becomes entry point for android. In React native there are two ways to run platform specific code one is by naming the files like (x.andoid.js or x.ios.js). Here the middle one tells which platform this file has to run on. Example, when you have two files x.android.js and x.ios.js when you run the code on the Android device the code in x.android.js, will be called and when you run it on iPhone x.ios.js will be called. While calling you will just call with name index.js. That's it. If you don't want to distinguish between two platforms and run the same code just you need to name it as index.js file

Answering another question of yours:

That android folder have native Android code inside. Same for iOS. All your code that cross platform you need to write in js files. It will start with index.js file by default

Upvotes: 3

Related Questions