1
我使用React進行了很多組件測試。最後,我在DOM(renderIntoDocument)和淺層渲染之間切換,我有兩個問題:React testing componentWillReceiveProps
- 爲什麼componentDidMount沒有在淺層渲染中觸發?
- 是否有可能使用DOM方法觸發componentWillReceiveProps?
感謝
我使用React進行了很多組件測試。最後,我在DOM(renderIntoDocument)和淺層渲染之間切換,我有兩個問題:React testing componentWillReceiveProps
感謝
有一個線程here,詢問一些方法淺渲染火componentDidMount
。
爲什麼它還沒有?可能是
a)淺層渲染仍在開發中,
b)淺渲染不渲染子項,並且componentDidMount
通常僅在渲染完所有子項後纔會渲染。
在this answer on SO似乎有解釋如何更新DOM方法/ renderIntoDocument,以火componentWillReceiveProps
。
有一個線程[這裏](https://gist.github.com/jondlm/514405bea50fad6fd905),要求以淺顯示的方式觸發componentDidMount。爲什麼它還沒有?可能是a)仍在開發中的淺層渲染和b)淺層渲染不會渲染子元素,componentDidMount通常僅在渲染完所有子元素後才呈現。在[這個答案在SO](http://stackoverflow.com/a/30616091/5358807)似乎有解釋如何更新DOM方法/ renderIntoDocument,以觸發componentWillReceiveProps。 – wintvelt
謝謝@wintvelt。對我來說這是一個很好的答案,如果你將你的評論移到回答,我會驗證它。 – samidarko