小编Lie*_*iem的帖子

需要将$ timeout和$ apply与requestAnimationFrame一起使用

我正在尝试使用requestAnimationFrame创建具有滚动编号的javascript动画

In order to see the see the animation rolling, I need to use a $apply to refresh the view. The problem here is when I start the animation, the digest cycle is already running so my $apply return an error "$apply already in progress".

Looking for a solution I use $timeout of 0 which work perfectly but I was wondering if there was other solution to avoid using a timeout that is not really good in terms of performance? …

timeout requestanimationframe angularjs angularjs-digest

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

单元测试:用酶反应上下文api返回一个空对象

我第一次尝试使用React上下文API将信息从主要组件传递给他的孙组件。

所以首先我创建了一个上下文 Context.js

这是定义上下文的主要组件 主要成分

父组件不关心上下文,而只是在这里创建大子组件 父组件

这是读取上下文的子组件 子组件

到目前为止没有问题。一切正常。ChildComponent已检索到上下文值。

问题出在我尝试用开玩笑/酶进行测试时。我无法设置上下文 单元测试

最后一个期望失败,并且上下文值是一个空对象。所以foo是不确定的

我在这里重新创建了问题:https : //codesandbox.io/embed/x25yop4x5w?fontsize=14

谢谢您的帮助

unit-testing reactjs jestjs enzyme react-context

2
推荐指数
2
解决办法
638
查看次数