小编Ale*_* N.的帖子

如何更改Sourcetree主题?

我在除了Source Tree之外的黑暗主题中使用了我所有的开发工具.

它的配置中没有选项来更改主题.

对于黑暗主题有没有其他方法可以改变?

themes atlassian-sourcetree

72
推荐指数
6
解决办法
4万
查看次数

React - 如何模拟 useFormContext (react-hook-form)

我在一个子组件中使用 useFormContext 。这是它的代码:

const { register } = useFormContext<CustomerProfileFormData>();
Run Code Online (Sandbox Code Playgroud)

我如何模拟 useFormContext 以便我可以测试子组件。这是测试

it('should render properly', () => {
    render(<AddressDetails isEdit={false} />);
    expect(screen.getByTestId('address-details')).toBeInTheDocument();
});
Run Code Online (Sandbox Code Playgroud)

我收到此错误 TypeError: Cannot destruct property 'register' of '(0 , _reactHookForm.useFormContext)(...)' 因为它是 null.Jest。

这是有道理的,因为我没有模拟 useFormContext 。我怎样才能模拟它?任何帮助将不胜感激。

reactjs react-hook-form

13
推荐指数
2
解决办法
3万
查看次数

ASP.NET Web API控制成功代码(200对201)

有没有办法为Web API控制器中的方法指定成功返回代码?

我的初始控制器结构如下

public HttpResponseMessage PostProduct(string id, Product product)
{   
var product= service.CreateProduct(product);
return Request.CreateResponse(HttpStatusCode.Created, product);
}
Run Code Online (Sandbox Code Playgroud)

但是,生成Web API帮助页面时,上述方法存在缺陷.Web API帮助页面API无法自动解码强类型产品是响应,因此在其文档中生成示例响应对象.

所以我采用以下方法,但这里的成功代码是,OK (200)而不是Created (201).无论如何,我可以使用一些属性样式语法来控制方法的成功代码?另外,我还想将Location标头设置为创建资源可用的URL - 再次,这在我处理时很容易做到HttpResponseMesage.

public Product PostProduct(string id, Product product)
{   
var product= service.CreateProduct(product);
return product;
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net asp.net-mvc asp.net-web-api

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