redux-reducers 相关问题


“在‘redux’中找不到导出‘createStore’

./node_modules/@redux-saga/core/dist/redux-saga-core.esm.js 中的警告 1343:21-28 “在‘redux’中找不到导出‘compose’ @ ./node_modules/redux-saga/dist/redux-saga-core-npm-proxy.esm.js ...


TypeScript Redux 在刷新页面时丢失状态

redux/reducer/cartReducer.ts 从“@reduxjs/toolkit”导入{createSlice,PayloadAction}; 从“../../types/reducer-types”导入{ CartReducerInitialState }; 导入 { 购物车项目,


为什么 Context API 在高频更新方面比 Redux 差?

我看到很多文章说Redux比高频更新在性能上比Context API更好,但没有具体说明原因。 是什么让人们说 Redux 比 Context API 更好......


React store.getState 不是一个函数

这是我的代码: 商店.js 从 'redux' 导入 {createStore, applyMiddleware, compose}; 从“不可变”导入{fromJS}; 从“react-router-redux”导入{routerMiddleware}; 导入createSagaMidd...


如何使用 redux tollkit 修复 Next 14 中的错误“请确保组件包裹在 <Provider> 中”?

我很难让 Next.js 14 与 Redux Provider 一起使用。我按照 Redux 官方文档上的所有说明进行操作,但我不断收到此错误: 错误:找不到反应-...


使用包装器时从非函数组件调用 React-Redux 调度函数

我有一个 React-Redux 存储,它包装在 next-redux-wrapper 中。我想在 React 组件之外调度一个函数,但由于包装器的原因我无法这样做。有办法导入吗


使用包装器时从非功能组件调用 React-Redux Dispatch 函数

我确实有一个react redux store,它包装在next-redux-wrapper中。我想在 React 组件之外调度一个函数,但由于包装器的原因我无法这样做。有没有办法让我...


Redux 工具包解析非 JSON 响应时出错

我正在尝试 redux 工具包,目前有以下切片和突变: 导出 const apiSlice = createApi({ 减速器路径:“api”, 基本查询: fetchBaseQuery({ 基本网址:“


React-Redux useSelector typescript type for state

我正在使用 React-Redux 中的 useSelector(state => state.SLICE_NAME) 挂钩,但是我在定义状态参数时遇到了困难。它默认设置为未知,因此当我尝试时会收到错误...


如何在 RTL 测试中使用 React Redux useDispatch 钩子?

我想在使用 redux 调度后测试 React 组件。我正在使用“test-utils.ts”文件中的自定义渲染函数: 从 'react' 导入 { ReactElement } 导入{渲染,渲染O...


我如何从react-redux中的api调用的数据中过滤值

我正在使用react和redux从API调用中获取数据,现在我创建了一个新变量并为其分配了相同的数据。在代码中,我将操作这个名为


使用 Redux 和 Typescript,如何正确键入“mapStateToProps”函数以仅允许通过状态传递 3 个参数中的 2 个?

我正在将 React 18 与 Redux 8 和 Typescript 结合使用。我想创建一个组件,允许调用者传入其中一个参数,但其他两个参数是从状态派生的。所以我创建了


Typescript 无法与 tsconfig.json 一起使用

在项目中使用 tsconfig 运行 tsc --watch 时,出现以下错误。 它需要 Node js 中的 React 和 Redux 类型。 错误 TS2688:找不到“abstract-leveldow...”的类型定义文件...


在操作中检测到不可序列化的值(redux-toolkit)

在store中action的payload中,我使用File类型存储下载的文件,然后该文件将在saga中通过验证 const form = new FormData(); if (私钥 &&


反应单元测试“不是函数”对象。<anonymous>

努力为使用 redux/sagas 的文件编写一些单元测试。 app.tsx 文件看起来像这样 从 'react' 导入 React, { StrictMode } 从'react-dom'导入ReactDOM 导入 { Provider } f...


office 插件中的 Redux DevTools

我正在开发一个使用 Angular 15 的 Excel 插件,在 Angular 应用程序中,我刚刚添加了 @ngrx/store。我也将开发工具添加到了模块中。我注意到 Excel 使用 Edge 来运行该加载项。


使用 WebSocket 和 React 构建通知面板时的推荐方法

我正在使用 websocket 和 React 构建一个通知面板。我应该使用 redux 工具包还是 useContext 来管理 Websocket 的集中位置?或者还有其他建议的方法吗...


如何在 Redux Saga 中使用 React Hook?

我正在为我的应用程序设置语言。但我有一个问题。 我使用 React.useContext() 来设置语言。但是当我在 saga 的 toast 中修复它时,它会记录: [错误:无效的挂钩调用。 Hooks 只能在 ins 中调用...


将 props 传递给 nextjs 中的页面组件

我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 导出类型 PageWithLayout = NextPage & { withLayout?:(页面:ReactElement)=> 我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 export type PageWithLayout<P = {}, IP = P> = NextPage<P, IP> & { withLayout?: (page: ReactElement) => ReactNode; }; 这是我的使用方法: export const Interactions: PageWithLayout = () => { const [ getInteractions, { data: interactionData, fetchMore, variables, loading: isInteractionsLoading, error: isInteractionsError, }, ] = useGetInteractionsLazyQuery({ notifyOnNetworkStatusChange: true, fetchPolicy: "network-only", ssr: false, }); return ( <> <Box height={"100vh"}> </Box> </> ); }; Interactions.withLayout = (page: ReactElement) => { // how do I pass isInteractionsLoading as a prop to this component return <Layout>{page}</Layout>; }; export default Interactions; 我想要实现的是将 isInteractionsLoaded 和 isInteractionsError 作为属性传递给我的布局组件,以便我可以渲染这些状态。有没有一种方法可以实现此目的,而无需将布局组件移动到页面组件内? 创建一个包装组件的 React Context 提供程序可能是您使用的解决方案,如果您不想使用任何其他包或不想使用 redux 等更强大的工具,则可以使用。 但是在这里使用有点尴尬,具体取决于包含交互的组件树是什么样子。否则可以根据您的需要使用 _app 入口点。 示例上下文和用法 import React from 'react'; export const InteractionContext = React.createContext({ isInteractionsLoading: false, isInteractionsError: null, }); // parent component or _app if necessary const ProviderComponent = () => { return ( <InteractionContext.Provider value={{ isInteractionsLoading, isInteractionsError }}> <Interactions /> </InteractionContext.Provider> ); }; const Layout = ({ children }) => { const { isInteractionsLoading, isInteractionsError } = useContext(InteractionContext); // Now you can use isInteractionsLoading and isInteractionsError here // ... return <div>{children}</div>; };


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