小编yus*_*ush的帖子

JestJS TypeScript:类型上不存在模拟实现

我正在使用 TypeScript 学习 Jest,但遇到以下类型错误:

Property 'mockImplementation' does not exist on type '() => Element'.
Run Code Online (Sandbox Code Playgroud)

代码:

Property 'mockImplementation' does not exist on type '() => Element'.
Run Code Online (Sandbox Code Playgroud)

我尝试过强制转换any,但这似乎无法解决问题:

Home.mockImplementation((): any => <div>HomePageMock</div>)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

TIA

typescript jestjs

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

React Hook Form 和 React Select 未按预期工作

我试图Controller按照文档(https://react-hook-form.com/get-started#IntegratingControlledInputs)使用包装器组件将 React Select 包装在 React Hook Form 内

            <Controller
              name="ShiftCaptain"
              control={control}
              render={({ field }) => (
                <Select
                  {...field}
                  value={selectValue}
                  options={options}
                  placeholder={"Select Person"}
                  onChange={(e) => setSelectValue(e)}
                />
              )}
            />
Run Code Online (Sandbox Code Playgroud)

提交表单时,React Select 中捕获的值不会填充到 React Hook Forms 中: 在此输入图像描述

有任何想法吗?

TIA

reactjs react-select react-hook-form

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

SQL Server:具有多个列的 GROUP BY 会产生重复的结果

我试图将第三列包含到现有的 SQL Server 查询中,但我得到了重复的结果值。

以下是 中包含的数据的示例tb_IssuedPermits

| EmployeeName | Current |
|--------------|---------|
| Person A     | 0       |
| Person A     | 0       |
| Person B     | 1       |
| Person C     | 0       |
| Person B     | 0       |
| Person A     | 1       |
Run Code Online (Sandbox Code Playgroud)

这是我当前的查询,它根据 1 或 0 位值生成重复值。

| EmployeeName | Current |
|--------------|---------|
| Person A     | 0       |
| Person A     | 0       |
| Person B     | 1       |
| …
Run Code Online (Sandbox Code Playgroud)

sql sql-server

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