Varun Singhal
1 min readDec 11, 2021

React Native

1- How we create custum console for ease

window.consolejson = json => console.log(JSON.stringify(json,null,2) Usage of this below Example

useEffect is Hook with two parameter first is event callback and other is dependencies

useEffect ( ()=>{

var dict = {“hello”:”dd”}

consolejson(dict)

},[])

2) Primitive Data type vs Reference Data type

Primitive Data type are those data type that is no object and has no method

number,undefined,bigint,symbol,boolean,null,undefined

Refernce Data type that are passed b reference

var a = “1”

var b = “1”

a== b (true)

var c = [“1”]

var d = [“1”]

c==d (false)

variable is used for hold a data

var a ;

var b ,

b = a

b[0] = 1

consolejson(a,b). o/p 1,1s

typeOf (null) — object

typeOf(undefined) — undefined

typeof(string)- string

typeof(1)= number

typeof(boolan) = booleab

typeof (symbol ) — Symbol

3- Platform Specific Code

React Native provide a module detect a platform in which app is running

import {
Platform
} from ‘react-native’;

<Text style = {styles.color}> {Platform.OS == “ios” ? “IO” :”Android”}
>
</Text>

Output diffrent for different Platform

Here we defined Platform specific style attribute

color: {
marginTop: 32,
paddingHorizontal: 24,
…Platform.select({
ios:{
color:’red’
},
android:{
color:’black’
},
default:{
color:’yellow’
}
})

},

When your platform-specific code is more complex, you should consider splitting the code out into separate files. React Native will detect when a file has a .ios. or .android. extension and load the relevant platform file when required from other components.

4 — Detect Environment

if (__DEV__){

print(“Development”)

}else{

print(“Production”)

}

Varun Singhal
Varun Singhal

Written by Varun Singhal

React Native/iOS Developer (Mobile App Developer)

No responses yet