当整个React DOM树已经加载时,我如何触发一个动作?就像知道孩子的兄弟姐妹什么时候加载一样。我相信容器组件的componentDidUpdate只有在它完全呈现时才会触发(就像它的子组件已经呈现一样),但我发现事实并非如此。 例如: class ParentContainer extends Component {
// all of the children should be rendered by now? const scrollToEl =
</div> );当然,我的普通函数不能有ReactJS方法的componentDidMount()。因为它不是扩展React.PureComponent的类。我在一个ReactJS网络应用程序中使用这个函数。export default function Daw() {
componentDidMount() { // ** Cannot use this ReactJS method!?</