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

How can I regenerate ios folder in React Native project?

$
0
0

So a while ago I deleted the /ios directory in my react native app (let's call it X). I've been developing and testing using the android emulator but now I'd like to make sure it works on ios with xcode simulator etc.

So my current idea is to create a new react native bare project (let's call it Y) with ios folder, then follow these steps to rename Y so that it has the name of X and then moving the /ios directory from Y into X and trying to run-ios.

I'll update here how that goes, but I wondered if there is a better way and has nobody been in this situation before?

I've googled lots of things 'regenerate ios folder''deleted ios folder''add ios folder to existing..' and nothing helpful. Maybe my googlefu isn't good enough but if anyone has any suggestions, much appreciated.

Step 2 will be making sure it compiles because of dependencies and stuff but for now my goal is to just get the /ios folder back in the project and for React Native to be aware of it's existence (it has all the necessary config).

Thanks


Invariant violation and other errors in React Native projects

$
0
0

I'm trying to run React Native projects in the iOS and Android simulators from VS Code. I keep getting the error message in the attached screenshot. I've tried reinstalling and updating dependancies and nothing is working. Any ideas?

Thanks!

Screenshot of error

Is there a way to send local images to a component function?

$
0
0

I would like to send a series of local image files to a component so that they could be rendered.I haven't found any way to do it where images were from local storage. I've only seen it where the images had online links and those links were stored in an object where they were then pulled from.Is there a way I could store multiple locations in an object and then send that to the component?

Product.Component.js

const Product = ({ image }) => {    return (<View style={styles.container}><Text></Text><View><Image                    style={{ width: 225, height: 225 }}                    source={image}                /></View><View style={styles.button}></View></View>    )}

App.js

import Product from './components/Product.Component'import {Image} from 'react-native';export default class App extends React.Component {render() {    return (<Container style={styles.container} ><Product           style={{ width: 225, height: 225 } }<Image source={require('./assets/images/logo/myimage.png')}/>        /></Container >    );}

Enable landscape mode for iPad/tablet using react-native

$
0
0

I am working on a requirement where the mobile device would support only portrait mode while the tablet/iPad supports both portrait and landscape mode, I am not sure how to achieve the requirement using react-native

React-Native: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template

$
0
0

While executing npx react-native init MyProject I ran into the following error:

✖ Installing CocoaPods dependencies (this may take a few minutes)error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.

Which seems to be related to an earlier error displayed:

checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot checking whether the C compiler works... noxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'

XCode and its CLI seem to all run fine.

My configuration:

  • MacOS Catalina 10.15.1 (19B88)
  • NPM 6.11.3
  • React-Native 0.61.4
  • XCode 11.2.1 (11B500)

Any leads appreciated.

Problem displaying and adding values in Async Storage, general LifeCycle problem in React-Native

$
0
0

I have a Flat List which renders items, each item has x amount of calories and On Press I want to add that to my calorie counter, however through Async Storage it works well until I go back to my home screen and click on a new item, it adds the new values to the end of the "string" rather to an Int.

For example when I render the list and click two items they add up perfectly and my calories display correctly, I then press home, go back to the tracker, search a new item and it adds it to the end e.g

 totalCalories = 50 

when I go back to tracking and add an item worth 30 calories this gets displayed

totalCalories = 5030 rather than 80

Here is my code:

   export default class Tracker extends React.Component {  static navigationOptions = {  title: "Tracker", };constructor(props) {    super(props);    this.getData(); this.state = {  isLoading: true,  dataSource: null,  show: false,  totalCalories: 0,    }; }

Fetching API method:

fetchData = (item) => {    fetch(      `https://api.edamam.com/api/food-database/parser?ingr=${item}&app_id=${APP_ID}&app_key=${APP_KEY}`    )      .then((response) => response.json())      .then((responseJson) => {        this.setState({          itemArray: responseJson.hints,        });      })      .catch((error) => {        console.log(error);      });    Keyboard.dismiss();  };

The onPress function when an item is pressed, which also sets the data in Async Storage:

fetchOnPressOpacity = async (item) => {  // console.log(this.state.totalCalories);    this.state.totalCalories += item.food.nutrients.ENERC_KCAL;    try {      this.setState({});      await AsyncStorage.setItem("totalCalories",        JSON.stringify(this.state.totalCalories)      );    } catch (error) {      console.log(error);    }  };

Async getData function:

getData = async () => {    try {      const totalCalories = await AsyncStorage.getItem("totalCalories");    //  parseInt(totalCalories);      if (totalCalories !== null) {        this.setState({            totalCalories,        });      }    } catch (error) {}  };

Render:

render() {    const { navigate } = this.props.navigation;    return (<View style={styles.container}><Button title="clear" onPress={() => this.resetCalories()} /><Text> Total Calories: {console.log(this.state.totalCalories)}{this.state.totalCalories}</Text><View style={styles.viewForInputContainer}><TextInput            onChangeText={(text) => this.setState({ item: text })}            style={styles.textInputContainer}            clearTextOnFocus={true}><Text style={styles.textColour}> Search Food </Text></TextInput></View><Button          title="Search"          onPress={() => this.fetchData(this.state.item)}        /><View style={styles.ViewFilterContainer}><TouchableOpacity style={styles.ViewFilterContainer}><View style={styles.filterButtonView}><Text style={styles.filterText}> Filter </Text></View></TouchableOpacity></View><View style={styles.paddingForResultsContainer}><FlatList            style={styles.resultsBackground}            data={this.state.itemArray}            renderItem={({ item, index }) => (<TouchableOpacity                onPress={() => this.fetchOnPressOpacity(item, index)}><View style={styles.resultsContainer}><View style={styles.textView}><Text style={styles.resultsText}>                      {item.food.label}                      {item.food.brand}                      {index}</Text></View><View style={styles.nutritionResultsText}><Text style={styles.resultsTextSubInfo}>                      F: {Math.round(item.food.nutrients.FAT)}</Text><Text style={styles.resultsTextSubInfo}>                      C: {Math.round(item.food.nutrients.CHOCDF)}</Text><Text style={styles.resultsTextSubInfo}>                      P: {Math.round(item.food.nutrients.PROCNT)}</Text><Text style={styles.resultsTextSubInfo}>                      K/Cal: {Math.round(item.food.nutrients.ENERC_KCAL)}</Text></View></View></TouchableOpacity>            )}          /></View><View style={styles.buttonContainer}><View><Button              title="Tracker"              onPress={() => navigate("Tracker")}              color="white"            /></View><Button            title="Shops"            onPress={() => navigate("Shops")}            color="white"          /><Button title="Home" onPress={() => navigate("Home")} color="white" /><Button            title="Macros"            onPress={() => navigate("Macros")}            color="white"          /></View></View>    );  }

Keyboard changes all components placement in react native

$
0
0

I created an AuthForm component that I use for a sign up and sign in screen after styling the screen I noticed every time I click on the keyboard to type some input everything changes its original placement and some components overlay others and it turns into a mess, how can I fix this?

Here is the code i used

import React, { useState } from "react";import {  StyleSheet,  ImageBackground,  View,  TouchableOpacity,} from "react-native";import { Text, Button, Input } from "react-native-elements";import Icon from "react-native-vector-icons/MaterialIcons";import Spacer from "./Spacer";const AuthForm = ({  headerText,  errorMessage,  onSubmit,  submitButtonText,  subText,}) => {  const [email, setEmail] = useState("");  const [password, setPassword] = useState("");  return (<View style={styles.container}><Spacer><Text style={styles.Text1}>{headerText}</Text><Text style={styles.Text2}>{subText}</Text></Spacer><View style={styles.Input}><Input          style={styles.Input}          placeholder="Your email"          value={email}          onChangeText={setEmail}          autoCapitalize="none"          autoCorrect={false}          leftIcon={<Icon name="email" size={20} color="#B3C1B3" />}        /><Input          secureTextEntry          placeholder="Your password"          value={password}          onChangeText={setPassword}          autoCapitalize="none"          autoCorrect={false}          leftIcon={<Icon name="lock" size={20} color="#B3C1B3" />}        /></View>      {errorMessage ? (<Text style={styles.errorMessage}>{errorMessage}</Text>      ) : null}<Spacer><TouchableOpacity          style={styles.buttonStyle}          onPress={() => onSubmit({ email, password })}><Text style={styles.ButtonText}>{submitButtonText}</Text></TouchableOpacity></Spacer></View>  );};const styles = StyleSheet.create({  container: {    flex: 1,    //justifyContent: "center",  },  errorMessage: {    fontSize: 16,    color: "red",    marginLeft: 15,    marginTop: 15,    top: "35%",  },  buttonStyle: {    color: "#e8c0c8",    width: "45%",    height: "25%",    backgroundColor: "#fdc2e6",    justifyContent: "center",    alignItems: "center",    borderRadius: 15,    top: "150%",    left: "30%",  },  ButtonText: {    color: "#FFFF",  },  Text1: {    top: "420%",    left: "15%",    fontSize: 24,    color: "#ffffff",  },  Text2: {    top: "420%",    left: "15%",    fontSize: 14,    color: "#d9d9d9",  },  Input: {    top: "40%",    width: "70%",    left: "15%",  },});export default AuthForm;

React-native upgrade associated type errors

$
0
0

I upgraded react-native

"react": "16.9.0","react-native": "0.61.4",

to

"react": "16.11.0","react-native": "0.62.2",

I did ala everything react native upgrade helper documents

https://react-native-community.github.io/upgrade-helper/?from=0.61.4&to=0.62.2

but I encountered these errors

"associated type descriptor for Swift.ExpressibleByFloatLiteral.FloatLiteralType", referenced from:"associated type descriptor for Swift.ExpressibleByIntegerLiteral.IntegerLiteralType", referenced from:"value witness table for Builtin.Int32", referenced from:

enter image description here


Using NSURLProtocol with ReactNative

$
0
0

We have a WebView application were we are using NSURLProtocol to intercept all javascript calls in native. Now we are planning to use ReactNative but when we try the same it is giving below error:

No suitable request handler found.

Looks like ReactNative is intercepting all the calls and we need to register our class to listen for the URL request. We have searched on internet but could not found much document. Please help us on this.

Webp on React-Native

$
0
0

React-Native documentation mentions that webp is not supported on Android, but says nothing about IOS. Out of the box it does not seem to work, but after installing this plugin https://libraries.io/npm/react-native-webp I can use images downloaded from internet.

Problem is that local files give me an error

: "{"type":InternalError","message":"react-packager has encountered an internal error, please check your terminal error output for more details"}

Unfortunately "react-native log-ios" command merely shows the same error there.

This is how I use the webp file after installing the plugin.

<Image   source={require('../../assets/icon.webp')}/>

How can I use local .webp images on React-native iOS?

'expo' is not recognized as an internal or external command

$
0
0

After running npm install -g expo-cli and successfully installing the packages globally, expo is still not recognized as an internal or external command. Does anyone know how I might get around this issue using windows 10, or what to do in terms of something like a path variable.

Get value from Picker onValueChange in react-native

$
0
0

I am developing an app using react native.Already I have implemented a list of user data. One example of data is this.

UID234 {"name":"Chris","age":31,"traits":{"eyes":"blue","shoe_size":10}}

Here's my code.


import RNPickerSelect from 'react-native-picker-select';...<RNPickerSelect     onValueChange={(value) => console.log(value)} // そのユーザーのvalueを取る     // {console.log(to_user)}    items={[      { label: 'Chris', value: 'UID234' },      { label: 'Marge', value: 'UID345' },      { label: 'Yuri', value: 'UID456' }            ]}     style={pickerSelectStyles}     placeholder={{ label: '選択してください', value: '' }}     />

In this case, when I select Chris, I can see "UID234" is shown on the console.

What I want to do is to print "Chris" on the screen.How can I do that? Please help me...

How do I call a component in another file? React Native

$
0
0

I am new to React Native and I am confused about how to call a specific component function ('runDemo' in SQLData.js) in another file in order to get the data that I will then push into another component file to display. I am trying to keep my code as clean and understandable as possible so I am trying to split codes into separate files without cluttering.

The flow of my code is: Apps.js gets data from SQLData.js and sends it as a prop to FlatList.js which will then render it.

The results of my files below is throwing an "Invariant Violation. Tried to get frame for index out of range index NaN"

These are the 3 files below:

Apps.js - main file

import React from 'react';import CustomList from './components/FlatList';import SQLData from './components/SQLData';export default function App() {  return(    //Not too sure if this is the correct way!    var database = <SQLData /><CustomList data={database}/>  );};

FlatList.js - Used to return the Flatlist with data

import React, {useState} from 'react';...import ListItem from './ListItem';/** * Handles the FlatList structure. */export default function CustomList(props) {    //Sets up Getter , Setter , Initial Data    const [data, setData] = useState(props.data);    ...    //This is UI that will be returned    return(        //div block<View style = {styles.contentContainer}><FlatList                ListHeaderComponent = {header}                //Sets the data for FlatList                data = {data}                keyExtractor = { (item) => (item.id).toString()}                //Takes each item from the database and separates them into separate div and applies style to each one                ItemSeparatorComponent = { () => <View style={styles.itemSeparator}></View>}                contentContainerStyle={ {borderBottomColor:'grey', borderBottomWidth: 1} }                //Gets item and index pair and creates a ListItem with those as props                renderItem = { ({item, index}) => <ListItem item={item} index={index}/>}            /></View>    );};

SQLData.js - Used to read Data from local db file

import React, { useState } from 'react';import SQLite from 'react-native-sqlite-storage';...export default function importData(props) {  const [helperArray, setArray] = useState([]);  /** 1. First function to be called **/  function runDemo() {    loadAndQueryDB();  }  /** 2. Called when runDemo is called **/  /*   assigns variable 'db' to opened Database */  /*   Calls queryPeople(db) */  function loadAndQueryDB() {    db = SQLite.openDatabase({name : "users.db"}, openCB, errorCB);    queryPeople(db);  }  /** 3. Called when loadAndQueryDB is called **/  /*    Get the DB and applies a SQL call that if successful will call queryPeopleSuccess*/  function queryPeople(db) {    ...  }  /** 4.  [SUCCESS] Called when queryPeople SQL execution is successful **/  /*      results - a ResultSet object */  function queryPeopleSuccess(tx, results) {    var len = results.rows.length;    let localArray = [];    //Go through each item in dataset    for (let i = 0; i < len; i++) {      let row = results.rows.item(i);      localArray.push(row);    }    setArray(localArray);  }  return ({helperArray});};

UPDATE: FIXED

Apps.js

import React from 'react';import CustomList from './components/FlatList';import { Utils } from './helpers/Index.js';/** * App.js calls CustomList *///This uses functional instead of class componentexport default function App() {  const data = Utils.runDemo();  return(<CustomList data={data}/>  );};

NEW FOLDER CALLED 'helpers' containing Index.js and SQLData.js

Index.js

import * as Utils from './SQLData.js';// Export againexport {   Utils,};

SQLData.js

import React from 'react';import SQLite from 'react-native-sqlite-storage';let db;function runDemo() {    return loadAndQueryDB();}function loadAndQueryDB() {    db = SQLite.openDatabase({ name: "users.db" }, openCB, errorCB);    return queryPeople(db);}function queryPeople(db) {    const data = db.transaction((tx) => {        tx.executeSql('SELECT * FROM users', [], queryPeopleSuccess,         errorCB);        });    return data;}function queryPeopleSuccess(tx, results) {    ...    return localArray;}export {    runDemo,};

In my Components Folder "./components/FlatList.js

export default function CustomList(props) {    const [data, setData] = useState(props.data);    ...

Unsuccessful debug_token response from Facebook

$
0
0

I am running to this error for a couple of days while I am trying to find some solution for it

I am applying a Facebook authentication to my Expo app . Android everything is working as expected while is ios ONLY getting this error

[Error: Unsuccessful debug_token response from Facebook:{"error":{"message":"(#100) The App_id in the input_token did notmatch the ViewingApp","type":"OAuthException","code":100,"fbtrace_id":"AatQy0aKnSRI8b_pOTa4txS"}}]

While I am searching everybody is pointing that means the AppID or AppSecret provided to firebase is wrong but I am 100% sure it's right as it's working well with android and the user is being authenticated and added to users so my expectations there is something wrong with ios config

Notes

App is directing to FB successfully and return token through ios

Again I am 100% sure of my AppID and AppSecret is correct as I copied paste them

Expo CLI 3.21.9 environment info:    System:      OS: Windows 10 10.0.18363    Binaries:      Node: 12.18.0 - C:\Program Files\nodejs\node.EXE      npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD    IDEs:      Android Studio: Version  4.0.0.0 AI-193.6911.18.40.6514223    npmPackages:      expo: ~37.0.3 => 37.0.12      react: ~16.9.0 => 16.9.0      react-dom: ~16.9.0 => 16.9.0      react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4      react-native-web: ~0.11.7 => 0.11.7      react-navigation: ^4.3.9 => 4.3.9

enter image description here

I will be very grateful if someone is willing to help me with this

Thanks in advance

How to import a Pod module into a different Pod module for React Native?

$
0
0

I am trying to import a swift Pod (A) into an objective-C Pod (B) to use with a React Native project.

In B's podspec, I added the dependency for A.In the React Native Project's Podfile, I added both A and B and ran Pod Install.

Now, inside the code of B, whenever I try to #import A, it can't find it.

I'm very new to all of this, what am I missing?

How could I use A's method calls into B?

Thank you in advance!:)


Error trying to install react native, not building correctly when running pod install

$
0
0

I am trying to learn react native, and I'm running into an issue when trying to to install dependencies. I have installed CocoaPods and followed all steps via the documentation. I am unsure why I am getting this error. When running pod install and pod install --repo-update I am getting the following output:

tyler@Tylers-MacBook-Pro ios % pod install --repo-update     Updating local specs repositoriesAnalyzing dependenciesFetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`Downloading dependenciesInstalling DoubleConversion (1.1.6)Installing FBLazyVector (0.61.5)Installing FBReactNativeSpec (0.61.5)Installing Folly (2018.10.22.00)Installing RCTRequired (0.61.5)Installing RCTTypeSafety (0.61.5)Installing React (0.61.5)Installing React-Core (0.61.5)Installing React-CoreModules (0.61.5)Installing React-RCTActionSheet (0.61.5)Installing React-RCTAnimation (0.61.5)Installing React-RCTBlob (0.61.5)Installing React-RCTImage (0.61.5)Installing React-RCTLinking (0.61.5)Installing React-RCTNetwork (0.61.5)Installing React-RCTSettings (0.61.5)Installing React-RCTText (0.61.5)Installing React-RCTVibration (0.61.5)Installing React-cxxreact (0.61.5)Installing React-jsi (0.61.5)Installing React-jsiexecutor (0.61.5)Installing React-jsinspector (0.61.5)Installing ReactCommon (0.61.5)Installing Yoga (1.14.0)Installing boost-for-react-native (1.63.0)Installing glog (0.3.5)[!] /bin/bash -c set -e#!/bin/bash# Copyright (c) Facebook, Inc. and its affiliates.## This source code is licensed under the MIT license found in the# LICENSE file in the root directory of this source tree.set -ePLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"CURRENT_ARCH="${CURRENT_ARCH}"if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.    # it's better to rely on platform name as fallback because architecture differs between simulator and device    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then        CURRENT_ARCH="x86_64"    else        CURRENT_ARCH="armv7"    fifiexport CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"export CXX="$CC"# Remove automake symlink if it existsif [ -h "test-driver" ]; then    rm test-driverfi./configure --host arm-apple-darwin# Fix build for tvOScat << EOF >> src/config.h/* Add in so we have Apple Target Conditionals */#ifdef __APPLE__#include <TargetConditionals.h>#include <Availability.h>#endif/* Special configuration for AppleTVOS */#if TARGET_OS_TV#undef HAVE_SYSCALL_H#undef HAVE_SYS_SYSCALL_H#undef OS_MACOSX#endif/* Special configuration for ucontext */#undef HAVE_UCONTEXT_H#undef PC_FROM_UCONTEXT#if defined(__x86_64__)#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip#elif defined(__i386__)#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip#endifEOF# Prepare exported header includeEXPORTED_INCLUDE_DIR="exported/glog"mkdir -p exported/glogcp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"checking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for arm-apple-darwin-strip... nochecking for strip... stripchecking for a thread-safe mkdir -p... ./install-sh -c -dchecking for gawk... nochecking for mawk... nochecking for nawk... nochecking for awk... awkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot checking whether the C compiler works... noxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: SDK "iphoneos" cannot be locatedxcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'/Users/tyler/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da/missing: Unknown `--is-lightweight' optionTry `/Users/tyler/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da/missing --help' for more informationconfigure: WARNING: 'missing' script is too old or missingconfigure: error: in `/Users/tyler/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da':configure: error: C compiler cannot create executablesSee `config.log' for more details

I have tried googling this problem but have had no luck. Any help is greatly appreciated it!

iOS app closes/crashing after splash screen only in Debug configuration mode

$
0
0

My app works absolutely perfectly on the simulator and when it is distributed as a Release configuration via my CI - all good. However, if I distributed it in Debug configuration (everything else remains the same) it always automatically closes or crashes straight after splash screen.

I was trying to export it as a development and development provisioning profile and adhoc and adHoc provisioning profile same result.

I have been battling with this issue for a few days now, please advise where to start and how to identify where the problem is.

I am running XCode 11.5 and the app has been developed using react-native. I am using crashalytics to capture the crash reports but for some reason, there is nothing in there.

react native custom sound remote notification(firebase)

$
0
0

I want to use custom sound on remote notification appears.Especially for IOS , in latest firebase library react-native-firebase/messaging(@6.7.1)lease help me regarding this.onNotification action is not performingBelow is the snippet of code i used.I have a react native app, Its a react hooks based app, where i want to play custom music based on notification payload data. And its working only when app is opened, But i want to play the custom sound when app is in background too.

   async componentDidMount() {let res = await retrieveItem('user').then((response)=>{if(response != null){messaging().setBackgroundMessageHandler(async (remoteMessage) => {console.log('Message handled in the background!', remoteMessage);// alert('hello1')});messaging().onMessage(async remoteMessage => {if(Platform.OS=='ios'){console.log('enter background notif',remoteMessage)PushNotification.localNotification({alertAction: "view", // (optional) default: viewcategory: "", // (optional) default: empty stringuserInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)title: remoteMessage.notification.title, // (optional)message: remoteMessage.notification.body, // (required)soundName:'Alarm'// playSound: false, // (optional) default: true});// alert('hell7o')}});messaging().onNotificationOpenedApp(async (remoteMessage) => {console.log('Notification caused app to open from background state:',remoteMessage);});messaging().getInitialNotification().then(async(remoteMessage) => {if (remoteMessage) {console.log('Notification caused app to open from quit state:',remoteMessage);}});this.props.BaseStore.userStore.user=responsethis.props.BaseStore.userStore.docid=response.idthis.props.BaseStore.userStore.type=response.typethis.props.navigation.navigate('Home')console.log(response.type);}}).catch((error)=>{console.log(error)})console.log(this.props.BaseStore.userStore.type)// this.set(this.props.BaseStore.userStore.type)}

How to resolve "Animated: `useNativeDriver` is not supported because the native animated module is missing." in react-navigation?

$
0
0

I am working on expo SDK Version: 36, and on all platforms (ios/android/web)

When installing react-navigation for the first time as described in the documentation and running jest --watch while doing it, and the following warning appeared:

    console.warn node_modules/react-native/Libraries/YellowBox/YellowBox.js:71      Animated: `useNativeDriver` is not supported because the native animated module is missing. Falling back to JS-based animation. To resolve this, add `RCTAnimation` module to this app, or remove `useNativeDriver`. More info: https://github.com/facebook/react-native/issues/11094#issuecomment-263240420

It also happen in the browser console:

bundle.js:18272 Animated: `useNativeDriver` is not supported because the native animated module is missing. Falling back to JS-based animation. To resolve this, add `RCTAnimation` module to this app, or remove `useNativeDriver`. More info: https://github.com/facebook/react-native/issues/11094#issuecomment-263240420     in Card (at CardContainer.tsx:132)    in CardContainer (at CardStack.tsx:499)    in CardStack (at StackView.tsx:384)    in KeyboardManager (at StackView.tsx:382)    in Context.Consumer (at StackView.tsx:380)    in StackView (at StackView.tsx:41)    in StackView (at createStackNavigator.tsx:33)    in Anonymous (at createNavigator.js:80)    in Navigator (at createAppContainer.js:351)    in NavigationContainer (at AppCore.js:15)    in AppCore (at App.js:14)    in App (at withExpoRoot.web.js:13)    in ExpoRootComponent (at registerRootComponent.web.js:6)    in RootComponentwarn @ bundle.js:18272r @ backend.js:6shouldUseNativeDriver @ bundle.js:76326TimingAnimation @ bundle.js:76894start @ bundle.js:75709start @ bundle.js:75715Card._this.animate @ bundle.js:85843componentDidMount @ bundle.js:85980commitLifeCycles @ bundle.js:52243commitLayoutEffects @ bundle.js:55486callCallback @ bundle.js:30478invokeGuardedCallbackDev @ bundle.js:30527invokeGuardedCallback @ bundle.js:30582commitRootImpl @ bundle.js:55224unstable_runWithPriority @ bundle.js:92068runWithPriority$2 @ bundle.js:42291commitRoot @ bundle.js:55064finishSyncRender @ bundle.js:54471performSyncWorkOnRoot @ bundle.js:54449(anonymous) @ bundle.js:42341unstable_runWithPriority @ bundle.js:92068runWithPriority$2 @ bundle.js:42291flushSyncCallbackQueueImpl @ bundle.js:42336flushSyncCallbackQueue @ bundle.js:42324scheduleUpdateOnFiber @ bundle.js:53851enqueueSetState @ bundle.js:44136../../../react/cjs/react.development.js.Component.setState @ bundle.js:88125_callee2$ @ bundle.js:1353tryCatch @ bundle.js:90193invoke @ bundle.js:90419prototype.<computed> @ bundle.js:90245tryCatch @ bundle.js:90193invoke @ bundle.js:90283(anonymous) @ bundle.js:90293Promise.then (async)invoke @ bundle.js:90292(anonymous) @ bundle.js:90293Promise.then (async)invoke @ bundle.js:90292(anonymous) @ bundle.js:90318callInvokeWithMethodAndArg @ bundle.js:90317enqueue @ bundle.js:90340prototype.<computed> @ bundle.js:90245../../../regenerator-runtime/runtime.js.exports.async @ bundle.js:90364_callee2 @ bundle.js:1324SplashScreen @ bundle.js:1537constructClassInstance @ bundle.js:44346updateClassComponent @ bundle.js:48555beginWork$1 @ bundle.js:50328beginWork$$1 @ bundle.js:55898performUnitOfWork @ bundle.js:54837workLoopSync @ bundle.js:54813performSyncWorkOnRoot @ bundle.js:54412(anonymous) @ bundle.js:42341unstable_runWithPriority @ bundle.js:92068runWithPriority$2 @ bundle.js:42291flushSyncCallbackQueueImpl @ bundle.js:42336flushSyncCallbackQueue @ bundle.js:42324scheduleUpdateOnFiber @ bundle.js:53851enqueueSetState @ bundle.js:44136../../../react/cjs/react.development.js.Component.setState @ bundle.js:88125onFinish @ bundle.js:1392_callee$ @ bundle.js:18446tryCatch @ bundle.js:90193invoke @ bundle.js:90419prototype.<computed> @ bundle.js:90245tryCatch @ bundle.js:90193invoke @ bundle.js:90283(anonymous) @ bundle.js:90293Promise.then (async)invoke @ bundle.js:90292(anonymous) @ bundle.js:90318callInvokeWithMethodAndArg @ bundle.js:90317enqueue @ bundle.js:90340prototype.<computed> @ bundle.js:90245../../../regenerator-runtime/runtime.js.exports.async @ bundle.js:90364_callee @ bundle.js:18389componentDidMount @ bundle.js:18470commitLifeCycles @ bundle.js:52243commitLayoutEffects @ bundle.js:55486callCallback @ bundle.js:30478invokeGuardedCallbackDev @ bundle.js:30527invokeGuardedCallback @ bundle.js:30582commitRootImpl @ bundle.js:55224unstable_runWithPriority @ bundle.js:92068runWithPriority$2 @ bundle.js:42291commitRoot @ bundle.js:55064finishSyncRender @ bundle.js:54471performSyncWorkOnRoot @ bundle.js:54449scheduleUpdateOnFiber @ bundle.js:53840updateContainer @ bundle.js:57245(anonymous) @ bundle.js:57670unbatchedUpdates @ bundle.js:54575legacyRenderSubtreeIntoContainer @ bundle.js:57669render @ bundle.js:57750renderApplication @ bundle.js:65334run @ bundle.js:65227runApplication @ bundle.js:65266registerRootComponent @ bundle.js:18777../../../expo/AppEntry.js @ bundle.js:14474__webpack_require__ @ bundle.js:727fn @ index.js:690 @ bundle.js:101987__webpack_require__ @ bundle.js:727(anonymous) @ bundle.js:794(anonymous) @ bundle.js:797Show 40 more frames[Violation] 'requestAnimationFrame'

Related issues:

The last one offers a solution, but it says to open Xcode, while I am on Linux Debian 10. I do not have Xcode. I can use a Macbook and do the step but I am wondering:

  • Should I care when working on Linux?
  • Should I care when working on Macbook (if it happens)?
  • Should I care for the health of my app while testing? Under which circumstances?

Expo Cli - Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager

$
0
0

I faced this issue with the expo client. The project is working on both iOS simulator and Android emulator. But the issue arise when I use expo app on the actual device.

I ran expo start and it gave me a QR code to scan, which I scanned from my device. Which displayed this error.

If I replace the Drawer navigator with just home component without react-navigation it works. The problem arises when I return <Navigator /> in my App.tsx.

import React from 'react';import Navigator from './navigations';import {YellowBox, View, Text, SafeAreaView} from 'react-native';import {useFonts} from '@use-expo/font';YellowBox.ignoreWarnings(['VirtualizedLists should never ']);const App = () => {  let [fontsLoaded] = useFonts({    Poppins: require('./assets/fonts/Poppins-Regular.ttf'),'Poppins-Bold': require('./assets/fonts/Poppins-Bold.ttf'),'Poppins-Light': require('./assets/fonts/Poppins-Light.ttf'),  });  if (fontsLoaded) {    return (<><Navigator /></>    );  } else {    return (<SafeAreaView><View><Text>Loading</Text></View></SafeAreaView>    );  }};export default App;

enter image description here

This is package.json

"dependencies": {"@expo/vector-icons": "^10.2.0","@react-native-community/masked-view": "^0.1.10","@react-navigation/drawer": "^5.8.2","@react-navigation/material-bottom-tabs": "^5.2.10","@react-navigation/native": "^5.5.1","@react-navigation/stack": "^5.5.1","@types/react-native-snap-carousel": "^3.8.1","@use-expo/font": "^2.0.0","babel-plugin-module-resolver": "^4.0.0","expo": "~37.0.3","expo-font": "^8.1.1","expo-updates": "~0.2.0","intl": "^1.2.5","react": "~16.9.0","react-dom": "~16.9.0","react-native": "~0.61.5","react-native-gesture-handler": "^1.6.1","react-native-paper": "^3.10.1","react-native-reanimated": "^1.9.0","react-native-safe-area-context": "^3.0.3","react-native-screens": "^2.8.0","react-native-snap-carousel": "^3.9.1","react-native-unimodules": "~0.9.0","react-native-web": "~0.11.7"  },"devDependencies": {"@babel/core": "~7.9.0","@types/react": "~16.9.23","@types/react-native": "~0.61.23","babel-preset-expo": "~8.1.0","jest-expo": "~37.0.0","typescript": "~3.8.3"  },
Viewing all 16566 articles
Browse latest View live


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