我有下面的类,当我运行我的lint时,我得到了道具验证错误。 `children` is missing in prop validation react/prop-types
// test-utils.js
import React from 'react'
import { render as rtlRender } from '@testing-library/react'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
嗯,我正在学习redux,但我有点怀疑如何最好地使用api
我有应用程序:
import React,{Component} from 'react';
import logo from './logo.svg';
import './App.css';
import Home from './components/HomePage';
import { Provider } from 'react-redux';
import store from './store';
class App ext
我正在构建一个非常简单的联系人应用程序来熟悉React和Redux。现在,我正在尝试构建添加联系人的功能。我认为我已经正确地设置了action和reducer,但是目前传递给我的reducer的状态是空的。我希望当前的联系人列表处于传递的状态。如果我在执行reducer后记录状态,它甚至没有得到我期望添加的联系人,它仍然是空的。当我向输入字段添加一些文本并单击“添加联系人”时,我得到一个错误Cannot convert undefined or null to object
在add contact reducer中,传入的状态为空,我认为这就是我的问题所在。我希望这个reducer将状态作为
我正在测试一些react组件,这是一个基本的测试套件,目的是了解组件是否正在呈现及其子程序。
我使用redux-mock-store来创建存储,使用{mount} enzyme在提供程序中挂载容器,但是即使是模拟正确的存储,这个错误也总是被触发:
TypeError:无法读取未定义属性的“路径名”
下面是我非常致命的基本测试:
import React from 'react';
import { mount } from 'enzyme';
import configureStore from 'redux-mock-store';
i
我一直在尝试用我的react redux项目来实现redux-persist。这就是我所拥有的。
store.js:
import {compose, createStore, applyMiddleware} from 'redux';
import {persistStore, autoRehydrate} from 'redux-persist';
import {combineReducers} from 'redux';
import thunk from 'redux-thunk';
import reducer f
新的反应和还原,所以玩一些非常简单的代码,看看它是如何工作的。当我尝试将一个combineReducers方法传递给一个redux存储时,我会得到一个错误。如果我移除combinedReducers并将减速机直接传递给商店,一切都很好。
let store = createStore(rootReducer);
错误
未明错误:对象作为React子对象无效(找到:键{reducer}的对象)。如果您打算呈现一个子集合,则使用数组代替,或者使用createFragment( object )从React插件包装对象。检查应用程序的呈现方法。
为什么当我使用combineReducers时
我从react开始尝试一些东西。但我不断地得到错误的"Uncaught TypeError: (0 , _reactRedux.combineReducers) is not a function“这是我的演示配置文件
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware,compose } from 'redux'
import { Provider } from 'react-redu
我用的是最新的反应节。我想获得当前状态屏幕快照的状态,但是我得到了一个错误,即类型是空对象,还原器是“从不”,在尝试useSelector时我根本无法检测到状态,我也把存储放到了提供者中。
错误
TS2322: Type 'EmptyObject & { session: never; }' is not assignable to type 'ReactNode'.
index.js
root.render(
<Provider store={store}>
<BrowserRouter>
<App
我正在学习React和Redux,当我这样做的时候,我决定制作一个带有按钮的网页,点击按钮就会改变状态。在按钮下面,我想在另一个组件中显示当前状态。虽然单击按钮会更改状态,但它不会反映在组件中。下面是我的代码:
App.js
import React from 'react'
import Name from './Name'
import {changeName} from './Action';
export default function App () {
return (
<div>
我开始学习redux,并尝试使用redux-persist来存储数据。因为redux- PersistGate现在已经更新到了v5,并建议使用PersistGate。但我几乎找不到关于PersistGate的文档。我写了一些代码,但是这个错误发生在PersistGate(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.,这是我的代码:
store.js
import thunk from
我对Redux并不熟悉,所以尝试在我的应用程序中实现这一点--我得到了以下错误:
Uncaught TypeError: (0 , _index2.default) is not a function
关于如何实现Redux设置,并没有完整的文档。我知道这个网站:,但是这并没有多大帮助。
不知道我错过了什么?
这是我的档案:
Client.js
//Client entry
//Application modules
import React from "react";
import { Provider } from "react-redux";
impo