redux-toolkit 相关问题


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

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


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

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


“在‘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 ...


为什么 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调用中获取数据,现在我创建了一个新变量并为其分配了相同的数据。在代码中,我将操作这个名为


EF Core 脚手架数据和属性已更改

我有一个 WPF 应用程序(MVVM Toolkit),其数据模型是使用数据库中的 EFcore 工具搭建的。一个特定类的最终模型如下所示: 公共部分B类...


为什么我的 Unity VR 项目无法构建和运行? [已关闭]

我想为我的任务 2 统一创建一个游戏。我从包管理器(Open XR 和 XR Interaction Toolkit)下载了一个入门包,一切似乎都很顺利。我有一台 Mac,所以


当我尝试将 model.predict() 与 Keras 顺序模型一起使用时,出现意外的 Tensorflow ResourceExhaustedError

我使用的是 Python 3.9,并且安装了 Tensorflow 2.10 和 CUDA Toolkit 11.2 和 cuDNN 8.2,因为这是 Windows 10 上原生支持的最后一个配置。 我正在使用 NVI 进行训练...


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

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


Typescript 无法与 tsconfig.json 一起使用

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


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

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


升级到 React 18 后 React App 未渲染

`我的 React 应用程序运行良好,但升级到 React 18、mui v5 和 redux v5 后,它没有渲染任何内容。 在终端中,我得到: webpack 编译成功 但在 chrome 控制台中...


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 中调用...


此悬念边界在完成水合之前收到了更新。 React Native、Expo 路由器、Redux、Supabase

在 Expo 上启动开发服务器,在 localhost:8081 上的浏览器上打开,期望应用程序呈现,但出现错误: 这个悬念边界在完成水合之前收到了更新。这...


MAUI 8 - 如何更改弹出背景叠加颜色?

使用 MAUI 7.0,下一个代码允许更改弹出背景叠加颜色,但该代码不适用于 MAUI 8.0 使用 MAUI 7.0,下一个代码允许更改弹出窗口背景覆盖颜色,但该代码不适用于 MAUI 8.0 <maui:MauiWinUIApplication x:Class="TestMaui8.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:maui="using:Microsoft.Maui" xmlns:local="using:TestMaui8.WinUI"> <maui:MauiWinUIApplication.Resources> <Color x:Key="SystemAltMediumColor">Transparent</Color> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogBackgroundThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <StaticResource x:Key="ContentDialogBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <StaticResource x:Key="PopupLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <SolidColorBrush x:Key="SliderBorderBrush" Color="#1A73E8" /> <Style TargetType="Slider"> <Setter Property="BorderBrush" Value="{StaticResource SliderBorderBrush}"/> </Style> </maui:MauiWinUIApplication.Resources> </maui:MauiWinUIApplication> 有人知道为什么它不起作用以及如何修复它吗? 更新添加一些图片 CommunityToolkit Popup 没有 Overlay color 功能。您可以在 CommunityToolkit GitHub 页面上提出功能请求。 是的,您发布的上述代码曾经可以工作,但它不适用于具有最新 CommunityToolkit.Maui nuget 的 .NET8。 但是如果您想更改叠加颜色,这里有一个解决方法。 <toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ... Color="Black" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" > //make the size to be the full screen size <ContentView WidthRequest="1920" HeightRequest="1080"> <VerticalStackLayout WidthRequest="300" HeightRequest="300" BackgroundColor="Green"> <Image Source="dotnet_bot.png"/> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </ContentView> </toolkit:Popup>


将 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.