我尝试编写正在使用formik和yup验证的多个错误行。使用后this.createError(),它将错误消息转换为字符串而不是数组{errors: '4 errors occurred'}。
我所做的示例代码:
const messages = [
{ key: "length", message: "should have password at least 8 characters" },
{ key: "notRepeat", message: "should not repeat old password" }
];
this.createError({
path: `${this.path}`,
message: messages,
errors: messages
});
Run Code Online (Sandbox Code Playgroud)
我需要的是错误,我需要它作为消息返回([])康斯坦斯,然后我通过 UI 显示错误列表。
有任何意见或建议来解决这个问题吗?
谢谢。
我怀疑是否有 lint 来检查我们输入但不需要使用的 css 内联样式。
例如,
在 .js 文件中
line: {
borderBottom: '1px #ddd solid',
paddingBottom: '5px',
backgroundColor: 'white',
border: '1px solid #ddd',
padding: '10px',
marginTop: '10px',
marginBottom: '10px',
borderRadius: '5px',
textAlign: 'center',
},
container: {
},
Run Code Online (Sandbox Code Playgroud)
在调用 .js 的文件中
<div style={styles.line}>
Run Code Online (Sandbox Code Playgroud)
从示例来看,在使用样式的文件中不需要容器,或者在 styles.line 中不需要使用所有容器(放置太多超出实际使用的样式。)。是否有任何 lint 可以检测和警告、错误或自动删除我提到的那些?
谢谢。
我需要知道如何编写代码以使用react-router通过onClick刷新页面
我尝试使用history.push,但不起作用。
这是我的代码:
onClick() {
this.props.history.push(`/a/${this.props.a}`);
// window.location.reload();
}
goPage() {
return (
<Button onClick={this.onClick}>
Begin
</Button>
);
}
Run Code Online (Sandbox Code Playgroud)
如果有人知道,请建议我
谢谢
reactjs ×3
javascript ×2
css ×1
formik ×1
html ×1
lint ×1
react-redux ×1
react-router ×1
router ×1
yup ×1