我已经成功地开发了我的第一个React Native应用程序,但有很多警告消息。其中,最常见的是我收到了这样的警告消息。
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
i
在升级了以前的react原生0.60.....Im之后,有人警告我应该取消所有手动链接的第三方库(因为RN现在通过自动链接来处理它)。
然而,当我运行react-native unlink <depedency>时,我得到了错误Something went wrong while unlinking. Reason Expected [\n\r] but end of input found
有什么想法吗?
我尝试运行npx react-native init AwesomeProject来创建一个新项目。我曾经测试过它,但是它没有错误地创建了这个项目,但是它已经不再工作了。我不得不重新安装nodejs。
Node.js v17.7.1
/usr/local/lib/node_modules/react-native-cli/index.js:302
cli.init(root, projectName);
^
TypeError: cli.init is not a function
at run (/usr/local/lib/node_modules/react-n
当我单击按钮提交表单时,会收到以下警告:
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Formik@http://localhost:3000/static/js/vendors
我用创建-反应-应用程序构建了我的应用程序。在它的最近版本中,它在Jest中的引导测试设置中添加了一行来卸载组件(请参阅ReactDOM.unmountComponentAtNode(div))。
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<
我会卸载react-native-reanimated。摘除前有unlinked。
输出:
> npx react-native unlink react-native-reanimated
warn Calling react-native unlink [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/
我像Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.一样收到警告 我正在使用此代码进行useEffect清理,但仍然收到相同的警告。 useEffect(() => {
let
在我的测试中有以下警告:
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.
Please check the code for the ProtectedRoute component.
所以我检查了我的ProtectedRoute组件。此组件构建于react-router的Route组件之上,并在呈现路
我有一个罕见的用法,我需要在我的反应组件中注册多个根,并在组件卸载时销毁它们。显然,在根的呈现时,我会卸载它。我在root.unmount()后面调用root.render(...)来模拟这种情况。在以下示例中:
这将导致以下警告:Warning: Attempted to synchronously unmount a root while React was already rendering. React cannot finish unmounting the root until the current render has completed, which may lead to
我是从react开始的,在我的项目中,我已经到了每件事都能正常工作的地步,但是有这样的警告:
Warning: setState(...): Can only update a mounted or mounting component.
因此,我看了几个QA,尝试了一些解决方案(从componentWillMount和componentDidMount更改了componentWillMount调用),但是.警告总是在那里。
下面是代码的一部分:
REQUEST_URL = 'http://url/users.php';
(...)
module.exports = Rea