typescript - TypeScript 和 redux 工具包,createSlice:分配给函数参数“状态”的属性
问题描述
您好,我的 estlint 有问题:
分配给函数参数“状态”的属性。eslintno-param-重新分配
在这段代码上:
state.sideisOpen = action.payload;
interface SideBar {
sideisOpen: boolean;
}
const INITIAL_STATE: SideBar = {
sideisOpen: true,
};
const sideBar = createSlice({
name: 'toggleSide',
initialState: INITIAL_STATE,
reducers: {
toggleSide: (state, action: PayloadAction<boolean>) => {
state.sideisOpen = action.payload;
},
},
});
export const { toggleSide } = sideBar.actions;
export { sideBar };
解决方案
请尝试编辑您的.eslintrc
文件以使规则对您的情况不那么严格:
// .eslintrc
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'state',
]
}],
推荐阅读
- php - 选择从哪里开始而不是 substr mysql
- powershell - 在继续安装之前应关闭测试执行
- android - 光标不能移到第一个
- jsp - 在struts1中修改用逻辑迭代填充的表中的值
- unit-testing - 使用内容创建文件创建单元测试
- php - 通过直接调用图像源 url 来显示 Facebook 图像 - 我需要 FB API 吗?
- c# - 在 JS 中解析查询字符串以过滤结果
- vba - VISIO VBA - 在现有形状内定位形状
- java - 当注释的方法参数不是最终的时,IntelliJ 以一种意想不到的方式格式化它们
- python - 使用 scipy.stats 和 pandas 计算相关性及其统计意义