2016-02-29 52 views
1

我使用React进行了很多组件测试。最后,我在DOM(renderIntoDocument)和浅层渲染之间切换,我有两个问题:React testing componentWillReceiveProps

  • 为什么componentDidMount没有在浅层渲染中触发?
  • 是否有可能使用DOM方法触发componentWillReceiveProps?

感谢

+0

有一个线程[这里](https://gist.github.com/jondlm/514405bea50fad6fd905),要求以浅显示的方式触发componentDidMount。为什么它还没有?可能是a)仍在开发中的浅层渲染和b)浅层渲染不会渲染子元素,componentDidMount通常仅在渲染完所有子元素后才呈现。在[这个答案在SO](http://stackoverflow.com/a/30616091/5358807)似乎有解释如何更新DOM方法/ renderIntoDocument,以触发componentWillReceiveProps。 – wintvelt

+0

谢谢@wintvelt。对我来说这是一个很好的答案,如果你将你的评论移到回答,我会验证它。 – samidarko

回答

2

有一个线程here,询问一些方法浅渲染火componentDidMount

为什么它还没有?可能是
a)浅层渲染仍在开发中,
b)浅渲染不渲染子项,并且componentDidMount通常仅在渲染完所有子项后才会渲染。

this answer on SO似乎有解释如何更新DOM方法/ renderIntoDocument,以火componentWillReceiveProps

相关问题