我有以下函数,它以React.useRef()作为参数。
在测试它时遇到问题,我试图让useRef保存值并能够removeChild()。
当我运行测试时,我会得到以下错误。
TypeError: useRef.current.removeChild不是一个函数
这是因为在测试期间,我传递的是一个对象而不是一个useRef钩子函数。
如何传入模拟的useRef并能够在测试期间传递值和执行removeChild操作?
这就是实现。
export const postData = (
useRef, // this useRef is coming from the calling com
这是我Drupal网站上的json:
[
{
title: "I believe every human has a finite number of heartbeats. I don't intend to waste any of mine.",
uid: "gestor"
},
{
title: "Man must explore, and this is exploration at its greatest",
uid: "
我是个新手。我的问题是我的变量总是说它是未定义的。我想要做的就是显示这些变量,但不能对其进行解构。执行一个过滤函数,并返回一次浏览。成功检索到数据。通过解构它,某些变量包含的数组无法显示。有人知道怎么解决这个问题吗? TypeError: Cannot read property '0' of undefined 我的数据是这样的。 [
{
"_id": "12345",
"name": "I am first tour",
"startLocation": {
我还在学习react。从redux操作中检索数据并将其存储为props。我的问题是,在执行过滤函数后,我的变量是未定义的。我要做的是使用redux action中的数据,并显示这些变量。组件的状态变为未定义,并且视图上没有显示任何内容。有人知道怎么解决这个问题吗?
1) 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
我的反应很新,现在我正在尝试使用故事簿。当我使用npm run storybook时,会遇到下面的错误。我已经试过想办法了,但我还是不确定。
无法读取未定义(读取“类型”)TypeError的属性:无法读取未定义的属性(读取“类型”)
at isMdx (http://localhost:6006/vendors-node_modules_pmmmwh_react-refresh-webpack-plugin_lib_runtime_RefreshUtils_js-node_mod-3a4695.iframe.bundle.js:3504:30)
at mdxToJsx (http://loc