componentWillReceiveProps, componentDidUpdate for React Hook

后端 未结 8 1203
闹比i
闹比i 2020-12-25 11:00

I run into two challenges:

  • Even if, as per React guideline, derived state is discouraged, but some edge cases still need it.
    In terms of
8条回答
  •  清酒与你
    2020-12-25 11:33

    simply by using useEffect like this.

    useEffect( () => {
        props.actions.fetchSinglePost(props.match.params.id); //> I'm dispatching an action here.
    }, [props.comments]) //> and here to watch comments and call the action in case there is any change.
    

提交回复
热议问题