下面是我的代码:function State(){ var [data,set_data]=React.useState({version:1})set_msg(x=>x+'x') //just to force render
data.version+=1 //changing state in place, but it still
为了更新子组件中的props对象,通常使用生命周期方法ComponentWillReceiveProps。但我意识到,可以在不侦听ComponentWillReceiveProps的情况下更新子组件的props。例如,在以下名为App的组件中,子组件Comp能够在不侦听生命周期方法ComponentWillReceiveProps的情况下接收props。主要的App组件:
import React from 'react