Skip to main content

Posts

Showing posts with the label React native

Update Node on Mac and Windows

Using brew: brew update brew upgrade node Using nvm:   NVM (Node Version Manager) is a tool that allows you to manage multiple versions of Node on your system. You can use nvm to install, update, and switch between different versions of Node. To update your version of Node using nvm, do the following: 1. Check if you already have nvm installed on your system:   
nvm --version 2. If it's not installed, install nvm using this command:    
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash 3. Once nvm is installed, check your current version of Node by running the following command: 
node -v 4. Then update your version of Node using the following command:   
nvm install node --reinstall-packages-from=node 5. And finally, verify that your update is complete by rechecking your Node version:   
node -v ———————————————————————————————————— Using NPM: To update Node using NPM, do the following: 1. Open the Terminal and check your curren...

MOBX STORE SETUP

yarn add axios   yarn add lodash   yarn add mobx   yarn add mobx-react-lite   yarn add mobx-state-tree   yarn add @react-native-async-storage/async-storage yarn add mst-gql yarn add graphql-request

Build commands

yarn ios --simulator="iPhone 11 Pro" yarn ios --simulator="iPhone 11" yarn ios --simulator="iPhone X” nvm use 16.13.1 nvm use 16.14.0 yarn nx affected --target=typecheck --parallel=3 yarn nx affected --target=lint --parallel=3 yarn nx format:write

React Native Alert Modal

 import { Paragraph, Dialog, Portal, Provider } from 'react-native-paper'  const [isOpen, setIsOpen] = React.useState(false)   <SafeAreaView style={styles.container}> <Provider>      <TouchableOpacity style={style.connectionLabel} onPress={() => setIsOpen(true)}>       <Text style={style.connectionText}>{translate('home.connected')}</Text>       </TouchableOpacity>           <View>           <Portal>             <Dialog visible={isOpen} onDismiss={() => setIsOpen(false)}>               <Dialog.Title>Alert</Dialog.Title>               <Dialog.Content>                 <Paragraph>This is simple dialog</Paragraph>         ...

React native app | event2/event-config.h file not found

  ERROR : event2/event-config.h file not found react native app Sol :  Just change use_flipper! to use_flipper!({ 'Flipper' => '0.80. 0' }) Then either in ios folder, run pod install again, or in your react native project root directory, run npx pod-install again URL : https://stackoverflow.com/questions/66019068/event2-event-config-h-file-not-found

REACT NATIVE ITERATE ROWS WITH DIFFERENT COLOURS

 mytrip.tsx import React from 'react' import { View, Text, TouchableOpacity, Image } from 'react-native' import { useNavigation } from '@react-navigation/native' import { ScrollView } from 'react-native-gesture-handler' import { SearchBar } from '../../components' import { styles } from './styles' import TripComponent from './TripComponent' const mytripScreen = () => {   const navigation = useNavigation()   const [trips, setTrips] = React.useState(MYTRIPS)   const searchTrips = (t: string) => {     const newData = MYTRIPS.filter(function (item) {       const itemData = item.title ? item.title.toUpperCase() : ''.toUpperCase()       const textData = t.toUpperCase()       return itemData.indexOf(textData) > -1     })     setTrips(newData)   }   return (     <View style={styles.mytripMainContainer}>       <View style={styles.mytripInnerContainer...

JS to show time slots ( PROGRESS TIMER )

  function format(time) {        // Hours, minutes and seconds     var hrs = ~~(time / 3600);     var mins = ~~((time % 3600) / 60);     var secs = ~~time % 60;     // Output like "1:01" or "4:03:59" or "123:03:59"     var ret = "";     if (hrs > 0) {         ret += "" + hrs + ":" + (mins < 10 ? "0" : "");     }     ret += "" + mins + ":" + (secs < 10 ? "0" : "");     ret += "" + secs;     return ret; } console.log(format(34322)); REF :  Labstack

Android emulator not able to access the internet

Change the DNS address of your network to 8.8.8.8 (Google's DNS) or another of your preference: MacOSX: Open "System Preferences" Click on "Network" Select the network which your computer is connected and click on "Advanced" Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222" Select "Ok" and "Apply" Windows & Linux: https://developers.google.com/speed/public-dns/docs/using After that close the emulator and start it again. URL :  https://stackoverflow.com/questions/42736038/android-emulator-not-able-to-access-the-internet

REACT NATIVE DYNAMIC STAR RATING

  renderRatings ( rating ){     let stars = [];     // Loop 5 times     for (var i = 1; i <= 5; i++) {       // Set the path to filled stars       let path = <Icon name="star" style={{fontSize: 10, color: '#eb9534',marginHorizontal:2}}/>;       // If ratings is lower, set the path to unfilled stars       if (i > rating ) {         path = <Icon name="star" style={{fontSize: 10, color: theme.LIGHT_GREY_COLOR, marginHorizontal:2}}/>;       }       // Push the Image tag in the stars array       stars.push(path);     }     return (       <View style={{flexDirection:"row",marginTop: 5,}}>            { stars }       </View>     )   }     render () {   ...

REACT NATIVE FONT INTEGRATION

REFERENCE URL   Download required fonts https://www.1001freefonts.com/gobold.font  1. Create an assets folder at the root of your project directory  2. Create a fonts folder within the assets folder and place your font files here  3. In your package.json specify where the custom fonts are located   "rnpm": {       "assets": [ "./assets/fonts/" ]  }  4. Next run the command react-native link

REACT NATIVE DEVICE PERMISSIONS

Write uses permissions in  “Project/android/app/src/main/AndroidManifest.xml”     <uses-permission android:name="android.permission.INTERNET" />        <uses-permission android:name="android.permission.CAMERA" />     <uses-permission android:name="android.permission.RECORD_AUDIO"/>     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />     <!-- setMicrophoneMute() and setSpeakerphoneOn() -->     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />             <!-- setBrightness() & setScreenMode() & saveBrightness() -->     <uses-permission android:name="android.permission.WRITE_SETTINGS" />     ...

DATE PICKER REACT NATIVE USING FLATLIST

import React, { Component, Fragment } from "react"; import { StyleSheet, View, FlatList, Image, Text} from "react-native"; import { Appbar, TextInput, Caption, List, Button} from "react-native-paper"; import { Formik } from 'formik'; import * as yup from 'yup'; import DatePicker from 'react-native-date-picker'; const DATE_SCHEMA = yup.object().shape({     start_date: yup.string()     .required('Start Date Required'),   end_date: yup.string()     .required('End Date Required'), }); const IMAGE = require("../assets/voice/flag-blue.png"); export default class AlertButton extends Component {   state = {     start_date...

React native execute method at once

// Method to execute once in loop var global. count =   0 ;   handleRecording   =  ()  =>  {        var   executed   =   false ;      if  ( ! executed ) {                  executed   =   true ;          if ( count   ==   0 ){                    this . props . videoRecStart ( true );             count ++ ;         }       }       }