I can’t change the default React app

Asked

Viewed 990 times

2

I made some changes to the file index.android.js and saved, when running command React-Native run-android, the app remains the same!! The code is like this:

var React = require('react');
var Text = require('react-native').Text;
var AppRegistry = require('react-native').AppRegistry;

const App = function(){
 return (
   <Text>Meu primeiro app</Text>
 );
};

AppRegistry.registerComponent('app1', function(){ return App });

But there’s that same welcome message to Reset!!

  • I’m just curious, why doesn’t Voce use ES6+? Anyway, you can write as generated the project?

2 answers

1

How did Voce generate the project? Using create-react-native-app or directly with react-native init?

a) Projects generated with the create-react-native-app run straight from the file App.js without having to register the component with Appregistry.

b) Projects generated with the react-native init has as its starting point the index.ios.js or index.android.js

  • It was through the React-Native init, I was able to solve the problem through the Reload, with the R R command. However I still do not understand well why with the command React-Native run-android does not update the app on the device

  • How is Voce running the app on the device? If it was using Expo, it gave live Reload. Now using Android Studio would be something else... Checked if Live Reload was enabled in the development menu?

0

If your problem is related to Reload and if using the Android Studio it is necessary to recharge the application with the command R+R (press the button R twice) in the emulator, you also have the option to activate the Reload automatic with the command: Ctrl+M, after that, appears this menu in the image below:

inserir a descrição da imagem aqui

In that image mine Reload automatic is activated!

After activating, every time you make a change and save, automatically the application is reloaded in the emulator.

If you are using the Expo, there is no need to activate.

And finally, if you are using directly on the phone through USB debugging, just shake the phone that appears the menu for the Reload.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.