如何在展会中抑制特定警告

问题描述 投票:0回答:3

我低于警告

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

如何抑制它?

我已经尝试过以下方法(放置在

app.js
中的行下方),但没有一个有效。

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"])

谁能帮我压制它?

react-native expo warnings
3个回答
3
投票
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Asyncstorage: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications

0
投票

console.disableYellowBox = true; 添加到您的 index.js 文件中。为我工作。


-1
投票

这是一个警告。不要压制它。我猜您正在使用“react-native”包中的异步存储。相反,请安装

@react-native-async-storage/async-storage
并从此处使用它。

© www.soinside.com 2019 - 2024. All rights reserved.