我有一个多步骤表单应用程序,我正在努力解决如何保存我的redux状态并在刷新后重播它的例子?在应用程序中返回/转发按预期工作,但在浏览器刷新后,我之前的状态为空.理想情况下,我希望能够保存与路径相关的会话存储中的先前状态,以便我可以稍后重播,但我不知道如何轻松地做到这一点.有没有人这样做过,可以提供一些指示?谢谢.
我可能做了一些愚蠢的事情,但我无法让defaultProps工作.
export default class MyClass extends Component{
static propTypes = {
name: React.PropTypes.string.isRequired,
field: React.PropTypes.object.isRequired
}
static defaultProps = {
field: { value: '', errors: [] }
}
render() {
// blah blah
}
}
Run Code Online (Sandbox Code Playgroud)
我有依赖的代码this.props.field.value,并this.props.field.errors.length和我所有的测试都是吹起来TypeError: 'undefined' is not an object (evaluating 'this.props.field.errors.length'),应该不是我的默认道具给它的默认值?最初,我的field道具是一个空物.
我正在利用黄金图像测试来测试颤动中的简单无状态小部件。每隔几次测试运行,我都会将以下错误打印到控制台:
\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nThe following TestFailure object was thrown running a test (but after the test had completed):\n Expected: one widget whose rasterized image matches golden image\n"goldens/mywidget.png"\n Actual: _WidgetTypeFinder:<zero widgets with type "MyWidget" (ignoring offstage widgets)>\n Which: Golden "goldens/mywidget.png": Pixel test failed, 0.04% diff detected.\n Failure feedback can be found at\n/home/cirrus/project/test/widgets/failures\n\nWhen the exception was thrown, this was the stack:\nRun Code Online (Sandbox Code Playgroud)\n这令人愤怒有两个原因:
\n有没有办法设置差异阈值,以便忽略差异低于 5% 的测试,以避免我的测试输出过于冗长和嘈杂?
\n …我正在使用Harp创建一个站点,我想知道是否有一种方法可以使用Jade块和正常的!= yield工作方式.基本上,对于页面特定的脚本,我想将一个块传递给我的布局.目前,无论我在模板中的块中拥有什么,都会被传递到我的布局中.
例如:
// _layout.jade
html
head
title Hello, world
body
!= yield
div Random delimiter
block scripts
// index.jade
h1 Hello, world
block scripts
script(src='/some/script.js').
div Not working
Run Code Online (Sandbox Code Playgroud)
输出:
<html>
<head>
<title>Hello, world</title>
</head>
<body>
<h1>Hello, world</h1>
<div>Not working</div>
<div>Random delimiter</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?