Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master
Showing posts with label React Native. Show all posts
Showing posts with label React Native. Show all posts

Tuesday, January 4, 2022

Learn to Fix React Native JVM Heap Space Is Exhausted

 Add the below lines into the gradle.properties file. Below memory size can be configured based on the RAM availability

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m

Through GUI:

In the Settings, search for 'Memory Settings' and increase the IDE max heap size and Daemon max heap size as per the system RAM availability.





Tuesday, December 28, 2021

How to show json data in flatlist in react native

 1. Create json data. Format is given below


    JsonData.json


[
    {
        "id" : 1,
        "FirstName" : "Sandeep",
        "LastName" : "Rauniyar",
        "DOB" : "4-7-1990",
        "CovidVaccine" : "Pfizer BioNTech",
        "FirstDose" : "EN6888",
        "SecondDose" : "ER8861",
        "image": "https://bootdey.com/img/Content/avatar/avatar1.png"
    },
    {
        "id" : 2,
        "FirstName" : "Mukesh",
        "LastName" : "Verma",
        "DOB" : "10/29/1995",
        "CovidVaccine" : "JANSSEN",
        "FirstDose" : "2030020",
        "SecondDose" : "",
        "image": "https://bootdey.com/img/Content/avatar/avatar2.png"
    }
]


2. import JsonData.json

import PostData from "../Data/JsonData.json";


3. Set data


    const [data, setData] = useState(PostData.filter(item=>item.id ==1 ));
 


4. 


<FlatList
   data={data}
   keyExtractor= {(item) => {
   return item.id;
   }}
   renderItem={({item}) => {
   return (
     <View>
        <View style={styles.box}>
           <Image style={styles.icon1} source={{uri: item.image}} />
           <View style={styles.boxContent}>
           <Text style={styles.title}>First Name : {item.FirstName}</Text>
            <Text style={styles.description}>Last Name :  {item.LastName}</Text>
            <Text style={styles.description}>DOB :  {item.DOB}</Text>
        <Text style={styles.description}>Covid-19 Vaccine : {item.CovidVaccine}</Text>   
             </View>
                </View>
             
            </View>
          )
        }}/>







Tuesday, December 21, 2021

new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method

 To fix, add this to RNFSManager.java


// Required for rn built in EventEmitter Calls.
    @ReactMethod
    public void addListener(String eventName) {

    }

    @ReactMethod
    public void removeListeners(Integer count) {

    }

Example: for fix warning in react-native-fs add functions to 
node_modules\react-native-fs\android\src\main\java\com\rnfs\RNFSManager.java file.
Snapshots is given below.





Thursday, November 11, 2021

Package has been Ignored because it contains Invalid Configuration React Native Error Fix

 As a react native developer we face many kind of react native errors while developing apps. Sometimes you may come up with a warning in the terminal as given below:




This react native warning will finally leads to build error while trying to run your application. So, how to fix this particular error? All you need is to run npm install command on your terminal from your project folder. After that try running your project again using either react-native run-android or react-native run-ios command.





Monday, October 25, 2021

ReactNative Metro Bundler not starting automatically

 Replace the code with this one. The path of the file is -

node_modules\metro-config\src\defaults\blacklist.js


var sharedBlacklist = [

  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,

  /website\/node_modules\/.*/,

  /heapCapture\/bundle\.js/,

  /.*\/__tests__\/.*/

];


Snapshots is given below:



React Native Task :app:validateSigningDebug FAILED

 The problem is that the build is looking for the debug keystore and cannot find it.

Keystore file /home/sandeep/react native/react-native-redux/android/app/debug.keystore not found for signing config 'debug'.

There's an issue with the same problem in React Native GitHub. According to the page, you can solve it by creating a debug keystore. Quote from the thread:

You can generate the debug keystore by running this command in the android/app/ directory: 

keytool -genkey -v -keystore D:\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000


Copy the file from D drive and put in below location

/home/sandeep/react native/react-native-redux/android/app/debug.keystore