Reactjs 使用componentdidmount方法中传递给组件的数据

Reactjs 使用componentdidmount方法中传递给组件的数据,reactjs,Reactjs,下面我有一个名为PrivateDataSingle的组件。我能够将客户数据传递到此组件 无论我在哪里 <PrivateDataSingle customer={this.state.customer}/> : : 我想在componentDidMount方法中使用客户数据中包含的customerId。 这将作为api的一部分用于返回数据 似乎componentDidMount方法中不存在我的客户信息。我该怎么做 这个有吗 但它存在于组件的其他部分中 class P

下面我有一个名为PrivateDataSingle的组件。我能够将客户数据传递到此组件 无论我在哪里

    <PrivateDataSingle customer={this.state.customer}/> :
我想在componentDidMount方法中使用客户数据中包含的customerId。 这将作为api的一部分用于返回数据

似乎componentDidMount方法中不存在我的客户信息。我该怎么做 这个有吗

但它存在于组件的其他部分中

    class PrivateDataSingle extends PureComponent {
         state = {
           invoices:[]
         }

         componentDidMount() {
          const getCustomerId = customer.customerId; ??
          AXIOS_AUTHED.get(`${API}/customers/${getCustomerId}/invoices`)
            .then(res => {
              const invoices= res.data;
              this.setState({ invoices });
            })  
        }

      render() {
        return (
          <h2>Hello world</h2>
        );
      }
    }

    export default PrivateDataSingle;
class PrivateDataSingle扩展了PureComponent{
状态={
发票:[]
}
componentDidMount(){
const getCustomerId=customer.customerId??
AXIOS_authend.get(`${API}/customers/${getCustomerId}/invoices`)
。然后(res=>{
常量发票=资源数据;
这个.setState({invoices});
})  
}
render(){
返回(
你好,世界
);
}
}
导出默认私有数据单;

以这种方式渲染组件时:

<PrivateDataSingle customer={this.state.customer} />
const getCustomerId = this.props.customer.customerId;