小编AsZ*_*Zik的帖子

'+' 操作的操作数必须是两个字符串或两个数字。考虑使用模板文字 @typescript-eslint/restrict-plus-operands

我只是使用 tslint 但这块代码给我一个错误。

 const MemberNumber = 'MBR' + pinCode + sliceNumber
Run Code Online (Sandbox Code Playgroud)
Operands of '+' operation must either be both strings or both numbers. Consider using a template literal  @typescript-eslint/restrict-plus-operands
Run Code Online (Sandbox Code Playgroud)

我厌倦了模板方法再次抛出 tslint 错误。

const MemberNumber = `MBR${pinCode}${sliceNumber}`
Run Code Online (Sandbox Code Playgroud)
 Invalid type "any" of template literal expression  @typescript-eslint/restrict-template-expres
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题。

谢谢

typescript tslint

3
推荐指数
1
解决办法
3691
查看次数

循环依赖,节点是:“密码”,是的

我收到上述错误。不知道该物体发生了什么。下面是我的对象。

export const loginValidator = yup.object({
  login: yup.string().when('password', {
    is: (v) => v < 9999 && v > 999,
    then: yup.string().required('Phone No is required').matches(phoneRegExp, 'Must be 10 digits'),
    otherwise: yup.string().email().required('Email is required'),
  }),
  password: yup.string().when('login', {
    is: (m) => phoneRegExp.test(m),
    then: yup
      .string()
      .required('Pin is Required')
      .matches(/^[0-9]+$/, 'Must be only digits')
      .min(5, 'Must be exactly 5 digits')
      .max(5, 'Must be exactly 5 digits'),
    otherwise: yup.string().required('password is required'),
  }),
});

Run Code Online (Sandbox Code Playgroud)

我得到的错误

Error: Cyclic dependency, node was:"password"
Run Code Online (Sandbox Code Playgroud)

这是怎么回事谢谢!!

reactjs react-native yup formik

1
推荐指数
1
解决办法
2882
查看次数

Push 不是 redux 中的函数

我使用 redux 编写了一个简单的添加到购物车功能。当我尝试将产品添加到数组时,它会抛出错误:

state.products.push 不是一个函数。

初始状态

export const INITIAL_STATE = {
  products: []
};
Run Code Online (Sandbox Code Playgroud)

我使用 redux-sauce 来调度该操作。

减速器

export const AddToCart = (state, { item }) => ({
  ...state,
  products: state.products.push(item),
});
Run Code Online (Sandbox Code Playgroud)

redux react-redux

0
推荐指数
1
解决办法
2534
查看次数

标签 统计

formik ×1

react-native ×1

react-redux ×1

reactjs ×1

redux ×1

tslint ×1

typescript ×1

yup ×1