How to create a React Native app(2)? Setup by CLI

What extensions needed for VSCode?

  • copilot
  • ESLint
  • GitLens
  • Prettier
  • npm scripts

How to install React Native app?

npx react-native init MyApp --template react-native-template-typescript

How to config alias for relative path?

How to setup global variables?

  • Create globals.js
import { Platform } from 'react-native'

global.PLATFORM = Platform.OS
global.IS_ANDROID = Platform.OS === 'android'
global.IS_IOS = Platform.OS === 'ios'
global.IS_IPAD = Platform.OS === 'ios' && Platform.isPad
  • Import globals.js into root Component
import 'app/globals'
  • Edit .eslintrc
{
   "globals": {
     "PLATFORM": true,
     "IS_ANDROID": true,
     "IS_IOS": true,
     "IS_IPAD": true,
   },
   "extends": [...]
}
  • Usage
// TypeScript file

const globalAny: any = global

if (globalAny.IS_ANDROID) {
  ...
}

How to config env file?

How to config storybook?

Be the first to comment

Leave a Reply

Your email address will not be published.


*