
[英]Why does my editor say "'await' has no effect on the type of this expression"?
为什么我的编辑器 (PHPStorm) 说我不需要“等待”? 它工作正常... 这是代码: ...
[英]Why does my editor say "'await' has no effect on the type of this expression"?
为什么我的编辑器 (PHPStorm) 说我不需要“等待”? 它工作正常... 这是代码: ...
[英]Getting a 'Actions must be plain objects' error when trying to work with non-async code in Redux
我使用来自 Redux 站点的这些文档为我的 Redux state 管理创建了一个基本设置: https://redux.js.org/usage/usage-with-typescript 。 我的基本设置如下,基本上是从上面链接的 Redux 文档复制而来的: 商店.ts storeHook ...
[英]Is it a good practice to use a single reducer to set all states in Redux
我对 Redux 比较陌生,仍然掌握这个库的概念。 我试图了解使用单个减速器设置 state 是好事还是坏事? 这就是我的意思。 在大多数示例和教程中,我看到的slice.js文件具有多个按以下方式设置的 reducer: 切片.js :import { createSlice } from '@r ...
[英]Can't use multiple reducers with combineReducers, getting an unknown property warning on state
我的商店设置如下: 登录缩减器/切片如下所示: 计数器减速器/切片如下所示: 现在的问题是我无法通过这种方式访问这两个减速器的值,这应该是正确的方式(也根据 Redux Devtools): 做这样的事情: ...返回undefined ,但尝试执行state.counter.counterVal ...
[英]Redux reducer doesn't cause re-render after mapping to new array or using immer
在我的 redux reducer 中,我 map 超过 state 并复制内部项目,然后返回列表,该列表应该是一个新的引用,因此 reducer 应该导致重新渲染更改,但它没有。 下面的代码不会导致重新渲染。const initialState: Group[] = []; export def ...
[英]Working on a react redux project, when I make a axios.post action the payload is empty with store.getState() but it works without
这是用户中间件... 这是 userReducer: rootreducer: 最后是商店: 在 userMiddleware 中,如果我输入用户名:name@email.com 和密码:realpassword 而不是使用 store.getState().logInEmail 和 store. ...
[英]How to type function with generic async thunk as parameter?
我无法获得正确的类型以将异步 thunk 作为 function 的参数传递并传播其 3 个关联的泛型类型,以便在调用 function 时可以推断出它们。 我在文档中找不到任何关于如何处理这个问题的方法或解释。 除了打字,下面的示例在应用程序中按预期工作(公司代码,无法共享)。 我的具体用例是我 ...
[英]access store data from one slice to another slice in redux toolkit to pass custom param in API
个人资料切片:import { createSlice, createAsyncThunk } from '@reduxjs/toolkit' import { IMAGE_API, ACCESS_KEY } from "../../app/utils/constant"; export cons ...
[英]Any tips for mutating the state using redux-toolkit
我正在使用 redux-toolkit 和 React。 我知道基本的 redux(不使用 redux-toolkit)不允许改变原始 state。这就是为什么我选择 redux-toolkit 来做到这一点。 但是,我不明白使用 redux-toolkit 来改变 state 的禁止方法是什么。 ...
[英]extraReducers builder.addCase rejected state not showing Using Redux Thunk With Redux Toolkit With Typescript
我正在尝试使用 React 向端点发出 POST 请求。 在我的builder.addCase reducer 的 fulfilled state 上,生成了我的数据或在完成后返回给我,但是在我的builder.addCase reducer 的 rejected state 上,检查我的 Red ...
[英]React/Redux Toolkit TypeScript issue with useDispatch `Expected 0 arguments, but got 1`
我正在使用 React/Redux/TypeScript 组合一个 web 应用程序,我对 TypeScript 没有太多经验。对于注册用户流程,我在代码中遇到问题,出现错误: Expected 0 arguments, but got 1.ts(2554)当我尝试将新的用户表单数据传递给调度 f ...
[英]useDispatch doesn't dispatch to the reducer
我正在尝试将现有项目从createStore转换为configureStore 。 商店.js:export default configureStore({ reducer: { articlesList: loadArticlesReducer } }); 家.js:cons ...
[英]Want to know about react & redux
React 和 redux 之间的基本区别是什么? 反应和 redux 是一样的吗? 为什么我们应该使用 redux? 最后为什么叫react-redux呢? 我想知道这一点,我只是混淆了这两者。 ...
[英]Redux abstraction level in selectors with typescript
这是 redux 和 typescript 使用 connect 方法的默认实现 我想要来自不同组件的可重用选择器,我将我的选择器作为单独的函数,而不是像示例中那样在 object mapState 中。 所以我的简化版本的选择器是这样的: 选择器.js: 我想创建一个 function 接受 o ...
[英]Store some login information to be used throughout the application
我正在寻找一种方法来存储登录时捕获的一些信息。 此信息稍后将用于调用数据库。 这是 Redux 的用户案例吗? 我不需要存储函数,而是将 UID 字符串与另一个标识符一起存储。 寻找一些建议。 ...
[英]Can i have multiple Redux states (or a diferent structure) in my App?
Basiclaly,我有一个应用程序与多个减速器结合 combineReducers(),作为一个正常的 react-redux 结构,看起来像这样: 应用程序 State 减速机1 减速机2 减速机3 那么,有没有什么办法可以有这样的结构: 应用程序 State 1 减速机1 减速机2 St ...
[英]Property 'id' does not exist on type 'WriteableDraft<Note> | WritableDraft<{}>
我正在将我的 ReactJS / Redux Toolkit 应用程序转换为 Typescript。我面临的一个问题是我无法获取 state object 的属性: 我用 ** 突出显示了它们。 这是界面的样子: 这是最初的 state: 明明接口里有id属性,为什么说不存在呢? ...
[英]having trouble fixing dependency cycle in redux
我的 redux 操作之一需要访问管理 api 请求的 class。 但是在我的 api 请求 class 中,我写了一个需要导入数据存储的方法。 然后我开始收到以下错误: 初始化前无法访问“ WEBPACK_DEFAULT_EXPORT ” 我查找了错误并提到这是由于 dep 循环,似乎这种模式导 ...
[英]how to call multiple API and pass it on "one API" and only called "oneApi" on action.js of react redux?
我的 redux: action.js 有一些问题。 我试图在这个 API 中调用不同的 API,并在 controller.js 中调用这个唯一的 API。 问题来了:我有一个实际种植API,但实际种植中的数据与User和State API相关。之前,我尝试在controller.js上直接调用 ...
[英]Icon change not showing using Redux Tool
我这里的情况有两个组成部分。 第一个组件有一个输入字段,另一个组件显示图标和标题名称。 我使用了 Redux 工具包,当输入字段被写入任何内容时,图标会更改为另一个图标。 问题是图标没有改变我不知道为什么会这样,我想知道如何在组件中定义图标,如下面的代码所示。 输入的第一个组件的代码 图标更改组件的 ...