How to suppress a specific warning in expo - react-native

I am getting below warning
AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '#react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage
How can I suppress it?
I have tried the below method(placed below lines in app.js) but none are working.
import { LogBox } from 'react-native'
LogBox.ignoreLogs(['Warning: AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from `#react-native-async-storage/async-storage` instead of `react-native`. See https://github.com/react-native-async-storage/async-storage'])
import { LogBox } from 'react-native'
LogBox.ignoreLogs(["Warning: AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '#react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage"])
Can anyone help me to suppress it?

import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Asyncstorage: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications

Its a warning. Do not suppress it. I guess you are using Async storage from 'react-native' package. Instead install #react-native-async-storage/async-storage and use it from here.

Related

React Native BluetoothManager NativeModules NULL

I'm trying to use BluetoothManager in React Native, already did these steps:
I did fresh install with react-native init MyProject
Imported NativeMoludes in App.js: import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, NativeModules } from 'react-native';
Initialized BluetoothManager: const { BluetoothManager} = NativeModules;
And do alert(BluetoothManager); before return(...)
but it always alerts null. Did I miss something in the RN installation or the import?
I'm using React Native v.0.62.2. Please advice.
I would advise using https://github.com/innoveit/react-native-ble-manager or https://github.com/Polidea/react-native-ble-plx for everything bluetooth related in react-native
You are not importing BluetoothManager properly, You have to install this module,
https://github.com/innoveit/react-native-ble-manager
Link that module(if the auto-linking is not available but or pod install in the case of ios) with your project and then import like below
import BleManager from 'react-native-ble-manager';
Also here is an example of import and usage too.
https://github.com/innoveit/react-native-ble-manager/blob/master/example/App.js

Warning:"Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle."

Getting this warning in the console when React Native app gets built initially.
Can anyone help me with the reason why I am getting this?
Following are the specifications
react-native-cli: 2.0.1
react-native: 0.62.0
Node: v12.9.1
There are generally two categories of cycle warning: one from our own codebase, and another from node_modules packages such as react-navigation-fluid-transitions. In this case, I think it is react-native paper.
We could hardly do anything about the require cycle in node_modules unless the package authors fix it.
But you still wish to keep the package and ignore the warning:
import { YellowBox } from 'react-native'
YellowBox.ignoreWarnings([
'Require cycle:'
])
I fixed it by importing each component separately like this:
import Button from 'react-native-paper/src/components/Button';
import IconButton from 'react-native-paper/src/components/IconButton';
do similar wherever you are using sth from react-native-paper
in your package.json ensure react-native-paper is "react-native-paper": "^4.5.0",
Then
rm -rf node_modules
npm install
npm start --reset-cache
your react-native-paper warning will disappear
If you have multiple Providers wrapping your app, make sure your Provider imported from react-native-paper is way up above in the Hierarchy (there are exceptions like Redux's Provider).
I had multiple providers and had it between other providers, which I think created cycle imports. Fixed the problem when I moved it above the tree, just below redux's provider().
import React from 'react';
import { StatusBar } from 'react-native';
import { Provider } from 'react-redux';
import { Provider as PaperProvider} from 'react-native-paper';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { store } from './your/reduxStore';
import { someTheme } from './your/apptheme';
const App = () => (
<Provider store={store}>
{/* Make sure react-native-paper provider is high up the tree */}
<PaperProvider theme={muiTheme}>
<SafeAreaProvider>
<StatusBar translucent />
{/* Your other App Stuff Here */}
</SafeAreaProvider>
</PaperProvider>
</Provider>
);
export default App;
YellowBox is deprecated, use LogBox:
import { LogBox } from 'react-native';
LogBox.ignoreLogs([
'Require cycle:'
])
sadly the "Require cycles are allowed" warning is still shown in the logs
You can go to each path and remove the cycle.
For example, in node_modules\react-native-paper\src\components\Checkbox\Checkbox.tsx, remove the reference of CheckboxItem.
However, I don't know what the impact of this is.

Unable to resolve module 'react-redux'...module 'react-redux' does not exist in haste module map

The code in app.js file with import statements for react redux is created to display a header with a text called "Tech stack".
App.js
import React from 'react';
import { View } from 'react-native';
import { Header } from './components/common';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
const App = () => {
return(
<Provider store={createStore(reducers)}>
<View>
<Header headerText="Tech Stack" />
</View>
</Provider>
);
};
export default App;
This is the index file
index.js
import { AppRegistry } from 'react-native';
import App from './src/App';
AppRegistry.registerComponent(tech_stack, () => App);
While running this on the terminal, it throws a error saying unable to resolve module 'react-redux'.
Close the JS bundle(a terminal starts when you run app for first time) and rerun it using the command react-native start from the project path. Basically, you need to rerun the JS bundle after every package installation.
Install 'react-redux' by using
npm install --save react-redux
if you not installed it. By seeing your comment as you mentioned that you installed redux only.
Then restart the JS bundle by using
react-native start --reset-cache
I've faced this issue just now. actually, Our (you and I) main issue is naming the global state folder name is redux and the bundler falls in a conflict because there is a folder inside node_modules that name is redux too.
In fact, the main issue is this line:
import { createStore } from 'redux';
I renamed the resux stuffs folder to reduxStore instead of redux and then everything works properly.
This error occurs because you do not have Redux-Thunk middleware installed on your application. To install run:
npm install redux-thunk
Then, restart your application:
react-native start
More information: https://github.com/reduxjs/redux-thunk
I just ran into this problem and solved it by installing redux in addition to react-redux. Apparently, react-redux requires it.

Remove warning viewPagerAndroid with react native 0.59.5

After upgrading to react native 0.59.5, the app threw the following warning message on simulator:
viewPagerAndroid has been extracted from react-native core...
But there is no import of the viewPagerAndroid in the component file:
import React, { Component} from 'react';
import { SectionList, View, StyleSheet, Text, TouchableOpacity, Platform, AppRegistry } from 'react-native';
import Moment from 'moment';
import DeviceInfo from 'react-native-device-info';
import { GiftedChat } from 'react-native-gifted-chat';
How to remove the warning?
As of react-native 0.59.0 ViewPagerAndroid has been deprecated. You can see that in the changelog here.
That means that if you want to use ViewPagerAndroid in the future you will need to install it separately. You can see its repo here
You are probably seeing this warning even though you haven’t explicitly used ViewPagerAndroid because one of the dependencies that you are using used it.
Most commonly react-native-gesture-handler or react-native-tab-view both use ViewPagerHandler.
At the moment the warning is just that, a warning. It isn’t going to cause you any issues until support for ViewPagerAndroid is dropped.
You can suppress the YellowBox warning so it won’t show on device. Note even if you suppress the warning it will always show in the logs.
Import it from react-native
import { YellowBox } from 'react-native';
Then in your App.js
YellowBox.ignoreWarnings(['ViewPagerAndroid']);
You can read more about suppressing warnings here

Read app.json (or exp.json) programmatically

Is there a way to read the contents of app.json programmatically from within you app, so you could for example get the current version number and show it within an About screen?
You can access this through Constants.manifest. This includes your app.json config without any of the potentially sensitive information such as API secret keys.
import Constants from 'expo-constants';
Constants.manifest.version
For Expo SDK 35, I did this:
expo install expo-constants
in your .js:
import Constants from "expo-constants";
<Text> {Constants.manifest.description} </Text>
For expo SDK 33 use:
import Constants from "expo-constants";
{`v${Constants.manifest.version}`}
npm:
npm install expo-constants
OR
expo:
expo install expo-constants
About.js
import Constants from "expo-constants";
<Text>Version {Constants.manifest.version} </Text>
As of Expo SDK 46, use Constants.expoConfig. Source: https://github.com/expo/expo/discussions/17176
Newer versions of expo (I'm on 36) now import the variable differently
import Constants from 'expo-constants';
Read all about it here on the expo documentation site
When trying to use this line
import { Constants } from 'expo-constants';
Constants was showing up as undefined when logged to the console.
However, this code worked to display the app's version:
<template>
<text>version: {{ appVersion }}</text>
</template>
<script>
import * as Constants from 'expo-constants';
export default {
data() {
return {
appVersion: Constants['default']['manifest']['version']
}
}
}
</script>