Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 29764 articles
Browse latest View live

React-native fetch Api get response differs from debugging mode and normal mode

$
0
0

I tried to call an https request get method API using the Axios method, from server it responded 200 but on the server-side, the API is not hit. Don't know where the response is coming from, the same API I have tried using post-man, I got 200 status with updated response correctly. after that I started using react-native-debugger to debug the responses, I debugged with the network inspector and I have tried the same API, it got a correct response with 200. what will be the issue in this. Someone, please help me to find out this bug.

I have added the code below using fetch, the same is happening in Axios calls too. Also found one thing while enabling network inspector in react-native-debugger the API works perfectly.

fetch(requestUrl, {
       method: methods.get,
       headers: head,
     })
       .then(response => response.json())
       .then(responseJson => {
         console.log('res JSON', responseJson);
           alert('your todolist is completed!!');
        }
       })
       .catch(error => {
         console.error(error);
       });

React-native 0.61.2 with hermes disassembling index.android.bundle

$
0
0

I created a release build of my app with react-native 0.61.2 and enabled Hermes. In my Crashlytics I receive information about crashes along with stacktraces. Perviously I used to apply apktool to extract index.android.bundle from my apk, and it contained js code where I was able to find the issue by stacktrace.

But now using Hermes index.android.bundle seems to contain bytecode rather than js and I wasted a day trying to disassemble it. The last thing I tried was hbcdump tool mentioned in https://github.com/facebook/hermes/blob/master/doc/BuildingAndRunning.md, but all I get is "Error: fail to deserializing bytecode: Wrong bytecode version. Expected 73 but got 62"

What should I do to disassemble index.android.bundle created with Hermes? Any help is highly appreciated!

React Native : How to get the list of apps installed in mobile phone in react native

how to solve my problem with react native build error?

$
0
0

I'm trying to build a react-native project using "react-native run-android" command and I'm getting this error:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    Failed to install the following Android SDK packages as some licences have not been accepted. build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-28 Android SDK Platform 28 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

    Using Android SDK: C:\SDK\platform-tools

I have fully installed sdk number 28 and 29 and all sdk tools. I have also done "sdkmanager --licenses" in directory "sdk/tools/bin" but my problem still remains. can anybody help me?

React Native: onPress in Android side somehow triggers onNavigationStateChange

$
0
0

I have some code that I implemented a couple of months ago that fixed the ability for a user to who was reading an article on my app and wanted to click on a hyperlink inside that article, once having done so, the user would be taken to an external browser. This is the implementation:

<View style={styles.content}>
            {Boolean(this.props.article.VideoID) && (
              <VimeoVideo videoId={this.props.article.VideoID.toString()} />
            )}
            {Boolean(this.props.article.Summary) && (
              <Text style={styles.boldParragraph}>
                {this.props.article.Summary}
              </Text>
            )}
            {this.props.article.Sections.map(s => (
              <WebViewAutoHeight
                key={s.Body.substr(10)}
                source={{
                  //prettier-ignore
                  html: `<body style="font-family: -apple-system, Roboto, sans-serif; background-color: ${lightTheme.grey2} !important; color: ${v2Colors.charcoalDarkest}; font-size: ${moderateScale(14, 0.2)}px;">${s.Body}</body>`
                }}
                // onNavigationStateChange={event => {
                //   if (event.url !== uri) {
                //     Linking.openURL(event.url);
                //   }
                // }}
              />
            ))}
          </View>

The commented out part. It works for iOS but on Android, as soon as the user clicks on READ MORE, it takes them to open up another browser in their phone not sure of the connection because onPress={mainActionButtonPress} is what the user is pressing and mainActionButtonPress is connected to a function:

 _goto = article => {
    this.props.setSelectedArticle(article);
    this.props.navigation.navigate("ArticleDetails", { isRead: true });
  };

how is onNavigationStateChange property inside of AutoHeightWebView being triggered by the _goto function? So I looked into this further and my best guess is that when _goto triggers this.props.navigation.navigate("ArticleDetails", { isRead: true });, JavaScript executes everything inside of there including onNavigationStateChange even though it should only do so when event.url !== uri.

I was able to find a solution with:

 onShouldStartLoadWithRequest={request => {
   if (Platform.OS === "android") {
        const url = request.url;
             console.log(request);
             if (url !== uri) {
               Linking.openURL(url);
             }
              // return false;
             }
   }}

but then this somehow cancels out the iOS solution. So this is not working:

<WebViewAutoHeight
                key={s.Body.substr(10)}
                source={{
                  //prettier-ignore
                  html: `<body style="font-family: -apple-system, Roboto, sans-serif; background-color: ${lightTheme.grey2} !important; color: ${v2Colors.charcoalDarkest}; font-size: ${moderateScale(14, 0.2)}px;">${s.Body}</body>`
                }}
                // onShouldStartLoadWithRequest={request => {
                //   if (Platform.OS === "android") {
                //     const url = request.url;
                //     console.log(request);
                //     if (url !== uri) {
                //       Linking.openURL(url);
                //     }
                //     // return false;
                //   }
                // }}
                onNavigationStateChange={event => {
                  if (Platform.OS === "ios") {
                    if (event.url !== uri) {
                      Linking.openURL(event.url);
                    }
                  }
                }}
              />

I tried a ternary operator, but I got syntax errors all over the place. I need some help in getting these working on their respective platforms.

Build failed with an exception java.io.IOException: Permission denied

$
0
0

I'm trying to get a React Native project to run on my Linux Mint PC but I'm struggling to do so as I'm getting the following error message:

yarn android
yarn run v1.21.1
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: 1: /user/local/Android/Sdk/platform-tools/adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

FAILURE: Build failed with an exception.

* Wh

at went wrong:
    java.io.IOException: Permission denied

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
    Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

    FAILURE: Build failed with an exception.

    * What went wrong:
    java.io.IOException: Permission denied

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

        at checkExecSyncError (child_process.js:603:11)
        at execFileSync (child_process.js:621:15)
        at runOnAllDevices (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Permission denied

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Permission denied

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

    at checkExecSyncError (child_process.js:603:11)
    at execFileSync (child_process.js:621:15)
    at runOnAllDevices (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at buildAndRun (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at /home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Command.handleAction (/home/guilherme/Workspace/soccerama/soccerama-mobile-rn/node_modules/@react-native-community/cli/build/index.js:164:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

As far as I know It's something related to the gradle's permissions and I've tried the following:

chown -R username ./android/gradlew
chmod 777 -R ./android
chmod +x ./android/gradlew

But none of these seems to solve my problem. I'd appreciate if someone could help me out here.

java.lang.ArrayIndexOutOfBoundsException in facebook.react.uimanager.ViewGroupDrawingOrderHelper.getChildDrawingOrder in React Native

$
0
0

Hi i am working in react native 0.61.4 and i got crashes in android not for iOS.

java.lang.ArrayIndexOutOfBoundsException:facebook.react.uimanager.ViewGroupDrawingOrderHelper.getChildDrawingOrder(ViewGroupDrawingOrderHelper.java:98)

Android Crash only

https://github.com/facebook/react-native/issues/27610

I have also created issue but nothing seem to helpful

Can anybody tell me what is the actual error and how to fix this.

thanks

Expo Vector Icons Not Displaying

$
0
0

I have a detached Expo project that utilizes @expo/vector-icons, but it is not loading the vector icons on the release build variant.

In debug the vector icons display properly (see picture below), but in release, they do not display at all. I've tried running locally using expo start --no-dev --minify for local "release" testing, but still fail to get any icons on the device. enter image description here

Another issue that I have found is that the onLoad callback for Images is not working. I've had to use the following workaround on Android for images in order to get the images to load properly on Android.

if (Platform.OS === 'ios' ) {

    return (

        <View style={[style, styles.fullBackground]}>
            <Animated.Image 
                {...props}
                source={thumbnailSource}
                style={{ opacity: this.thumbnailAnimated }}
                blurRadius={2}
                onLoad={this.handleThumbnailLoad}
            />

            <Animated.Image 
                {...props}
                source={source}
                style={[styles.imageOverlay, { opacity: this.imageAnimated }, style]}
                onLoad={this.onImageLoad}
            />

        </View>

    );

} else {

    return (

        <View style={[style, styles.fullBackground]}>

            <Image 
                {...props}
                source={source}
                style={[styles.imageOverlay, { opacity: 1 }, style]}
            />

        </View>

    );

}

Here is my package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "postinstall": "jetify"
  },
  "dependencies": {
    "@react-native-community/datetimepicker": "2.1.0",
    "@react-native-community/slider": "^1.1.3",
    "@unimodules/core": "~5.0.0",
    "@unimodules/react-native-adapter": "~5.0.0",
    "@expo/vector-icons": "^10.0.0",
    "expo-ads-facebook": "~8.0.0",
    "expo-asset": "~8.0.0",
    "expo-facebook": "~8.0.0",
    "expo-google-app-auth": "^6.0.0",
    "expo-linear-gradient": "~8.0.0",
    "expokit": "^36.0.0",
    "geofire": "^5.0.1",
    "geofirex": "0.0.6",
    "geopoint": "^1.0.1",
    "lodash": "^4.17.11",
    "lodash.debounce": "^4.0.8",
    "moment": "^2.24.0",
    "react": "16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
    "react-native-animatable": "^1.3.2",
    "react-native-animated-linear-gradient": "^1.2.0",
    "react-native-app-intro-slider": "^2.0.1",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "~1.5.0",
    "react-native-indicators": "^0.13.0",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-linear-gradient": "^2.5.4",
    "react-native-map-link": "^2.4.5",
    "react-native-maps": "0.26.1",
    "react-native-mask-loader": "0.0.3",
    "react-native-modal": "^11.0.1",
    "react-native-reanimated": "~1.4.0",
    "react-native-share": "^1.1.3",
    "react-native-super-ellipse-mask": "^1.0.7",
    "react-native-swipeable": "^0.6.0",
    "react-native-text-gradient": "^0.1.5",
    "react-native-unified-contacts": "^2.0.0-pre.2",
    "react-navigation": "^3.11.1",
    "recyclerlistview": "^1.3.4",
    "rxjs": "^6.5.2",
    "expo-font": "~8.0.0",
    "expo": "^36.0.0"
  },
  "devDependencies": {
    "axios": "^0.19.0",
    "babel-preset-expo": "^5.0.0",
    "expo": "^36.0.0",
    "firebase": "^5.11.1",
    "firebase-admin": "^8.1.0",
    "geofirestore": "^3.3.1",
    "jetifier": "^1.6.5",
    "react-native-clean-project": "^3.2.1",
    "react-native-extra-dimensions-android": "^1.2.5",
    "react-native-firebase": "^5.2.0",
    "react-native-unimodules": "^0.5.4"
  },
  "private": true
}

I've tried quite a few different things, such as:

  • Removing node_modules and re-running npm install
  • Upgrading from Expo SDK 35 to Expo SDK 36
  • Re-checking Expo documentation on upgrading SDKs (This project originated as SDK 32)

I'm at a bit of a loss on why this is occurring. Even talked with some people from Expo and they were unsure about why this might be happening (especially the Image onLoad callback). It's worth noting that the iOS build works correctly in development and release.


Problema ao compilar um app react-native para meu dispositivo [closed]

Error calling ExpoPermissions while trying to ask for android permissions

$
0
0

I'm having an error while using the ExpoPermission interface. I just started to learn about Android development with React and Expo, followed a guide to create a new project

npm install -g create-react-native-app 
create-react-native-app my-app 
cd my-app/ 
npm start

Everything worked, and the example run on my phone, then i just added a simple button that calls the example from the expo documentation, but it launches this message when i press it.

[Error: Encountered an exception while calling native method: Exception occurred while executing exported method askAsync on module ExpoPermissions: null]

My code is simple, just added to the view

<TouchableOpacity onPress={handlePressMe} style={styles.helpLink}>
  <Text style={styles.LinkBlue}>
    Press me!
  </Text>
</TouchableOpacity>

Then added the code:

function handlePressMe() {
  request_storage_runtime_permission();
}

async function request_storage_runtime_permission() {

  try {
    const granted = await Permissions.askAsync(Permissions.WRITE_EXTERNAL_STORAGE);
    print(granted)
    Alert.alert("Storage Permission received.");
    /*if (granted === PermissionsAndroid.RESULTS.GRANTED) {

      Alert.alert("Storage Permission Granted.");
    }
    else {

      Alert.alert("Storage Permission Not Granted");

    }*/
  } catch (err) {
    console.warn(err)
  }
}

And import * as Permissions from 'expo-permissions';

I've read the documentation of Expo, and found many installs that said to do for this library, but none has changed anything, just in case, both things i've added

sudo expo install expo-permissions
sudo yarn add react-native-unimodules

Also to note that i added the permission to app.json, and tried to use getAsync to see if it had been granted, but launched the same error, this is my app.json:

{
  "expo": {
    "name": "Test App",
    "slug": "testApp",
    "privacy": "public",
    "sdkVersion": "35.0.0",
    "platforms": [
      "android",
      "web"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "android": {
      "permissions": [
        "WRITE_EXTERNAL_STORAGE"
      ]
    }
  }
}

Tried searching for more info, but only thing i found are unanswered topics. Does anyone knows what is the problem, or how to prompt more info? Only thing it shows is null.

Not able to get Firebase crashlytics in react native android appliction

$
0
0

I am trying to add Firebase Crashlytics in react native application. I have added all the dependencies as per firebase console suggestion but I am not getting any crash report on the console. I have implemented crash reports as per the native android code.

How to Unlock Screen After Timer?

$
0
0

I'm creating an alarm app in React Native that goes off after a timeout that uses the distance from the current time to the set alarm time.

I need to implement a method to unlock the screen when the alarm goes off (the app will be open in the foreground right when I lock the screen), then display an alarm ringing screen in the app (with vibration and sound). So far, I've only got the second half working.

I've tried using both react-native-alarm-notification and react-native-calendar-events, but from my understanding, these don't seem to contain methods to unlock the screen. Some other modules like wakeup-screen and unlock-device simply don't work for me. Please correct me if one or more of these packages actually can do what I mentioned, and if so how.

What are your suggestions for how to implement this?

Is it possible to build and run react native android app on CircleCi

$
0
0

How can I start an emulator and run the command that builds the android version (react-native run-android) so I can verify that the app is building correctly

How to implement Android splash screen using svg instead of png?

$
0
0

I make RN app. For Android version I have made /drawable/splash_screen.xml with following content

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

  <item
    android:drawable="@color/gray"/>

  <item>
    <bitmap
      android:gravity="center"
      android:src="@mipmap/ic_launcher"/>
  </item>

</layer-list>

and links to this file in res/values/styles.xml

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_screen</item>
</style>

also in AndoirdManifest.xml

<application
  android:name=".MainApplication"
  android:allowBackup="true"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/SplashTheme"
    android:screenOrientation="landscape"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

This works fine, but I'd like to make SVG file instead PNG (mipmap/ic_launcher). The SVG file might be like this https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html (at least without animation). How to achieve this?

Failed to launch emulator. Reason: Emulator exited before boot en React Native when react-native run-android

$
0
0

I am installing Reac Native according to this website https://medium.com/@leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea, its very useful until I run the command react-native run-android, this is the error what I recive

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 864 file(s) to forward-jetify. Using 8 workers... info Starting JS server... info Launching emulator... error Failed to launch emulator. Reason: Emulator exited before boot..

Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings 24 actionable tasks: 4 executed, 20 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

    Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.

    Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 7s

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\JesusApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)

My node version is 10, and I am working on windows, please help, thank you.


How do I resolve a Promise inside a Task?

$
0
0

I have a method wich should get a location and send it's result as a resolved Promise. However I have no idea how to await for the listener to finish or to workaround. It uses Google Services API to get current location.

// LocationModule.java
@ReactMethod
public void getLocation(String debugMessage, Promise promise) {
    try {
        this.fusedLocationClient.getLastLocation()
            .addOnSuccessListener(new OnSuccessListener<Location>() {
                @Override
                public void onSuccess(Location location) {
                    if(location != null) {
                        promise.resolve(location);
                    }
                }
            });
        // promise.resolve(debugMessage); this would be called before the promise above and if it isn't present here app crashes
    } catch(Exception e) {
        promise.reject("Something went wrong", e);
    }
}

React native sound is too slow when loading a sound from url (delay)

$
0
0

So i am making a mobile app with react native and i used react-native-sound for playing sounds in the app but i noticed that everytime i load the page that plays the sound it dosent play right away i have to wait for at least 10 seconds to hear it

NOTE: i am taking the sound from my website with a link that has the mp3 file retrieved from a buffer and you know how it goes .. i tried other websites but still the same .

    const track = new Sound(
      'https://example.com/voice/' + this.props.res._id,
      null,
      e => {
        if (e) {
          console.warn('error loading track:', e);
        } else {
          track.play();
        }
      },
    );
  }

so do you have any idea about this delay or how to get rid of it because when i open this link in the phone or pc browser it starts working instantly i just want the same think on the app and thank you..

Android unable to get object array from redux

$
0
0

I was new to react native, now i face a problem to retrieve object array data from redux. Same code working on ios simulator but on android emulator fail (TypeError:undefined is not an object)

onPressme = () => {
    alert(this.props.groupddl.groupDdl[0].label)
}

function mapStateToProps(state) {
    return {
        groupddl: state.attendanceReducers
    };
}

Reducer declare as groupDdl = []

Same code working on ios simulator, fail on android. Any solution will be appreciate. thanks

User role wise drawer navigation in react-native

$
0
0

I have added react-navigation-drawer for implementing drawer navigation in my app. I have created a file named PrimaryNav.js and added all navigation code in it.

import Login from './components/Login';
import Employee from './pages/Employee';
import { createAppContainer,SafeAreaView, } from 'react-navigation'
import { createDrawerNavigator, DrawerItems } from 'react-navigation-drawer';
import React from 'react';

const Primary_Nav = createDrawerNavigator({
    Login: {
      screen: Login,
      navigationOptions: {
        drawerLabel: () => null
      }
    },
    Home_kitchen: {
      screen: Home_kitchen,
      navigationOptions: {
        drawerLabel: "Home"
      }
    },
    Employee: {
      screen: Employee,
      navigationOptions:{
        drawerLabel:"Employee",
      }
    },
  },{
    initialRouteName:'Login',
    drawerPosition: 'left',
    drawerType: "slide",
    }
});

const PrimaryNav = createAppContainer(Primary_Nav);
export default PrimaryNav;

Something like above. I have called this file in the App.js, the issue I am facing is I need to set a drawer item based on the role which the user has. So if the user role is cashier he should not be able to see all the menu.

All the pages are coming properly in the drawer menu but the question is how should I want to manage menu role wise in my app and changed the menu based on the roles of the user?

Tabs with scrolling animated header - React native

Viewing all 29764 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>