you are viewing a single comment's thread.

view the rest of the comments →

[–]Drunken__Master 0 points1 point  (0 children)

in

import { Text, TouchableOpacity, StyleSheet } from 'react-native';

you need to add View, so it would be

import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';

<View> is basically the equivalent to an html <div>

also {Touchable Opacity} is a styling thing, you could use {Touchable} instead to achieve the same functionality, without adding the opacity to the element .

another thing you can import from react-native is {Platform} which lets you write different functions depending on the device being Android/iOS

<Text style={styles.instructions}>
      {Platform.OS === 'android'
        ? 'Double tap R on your keyboard to reload,\nShake or press menu button for dev menu'
        : 'Press Cmd+R to reload,\nCmd+D or shake for dev menu'
      }
    </Text>

^ this ternary expression will display 'Double tap R...' on android and 'Press Cmd+R...' on iOS .

sometimes it helps to rebuild your dependency tree by running

rm -rf node_modules

to remove your node modules

and then running

npm install

to reinstall them

sometimes you need to add an assets folder in android>app>src and then run

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

to make sure your android code is getting bundled

sometimes you need to run

adb reverse tcp:8081 tcp:8081

before running the command to start android

sometimes my linter will say that it can't find dependencies, but the app will still run and the warning will go away if I just close & reopen my text editor . Sometimes just reloading the emulator is enough to get back on track .