【发布时间】:2020-12-08 12:49:50
【问题描述】:
谁能告诉我使用钩子的等效代码:
componentDidMount() {
const { match: { params } } = this.props;
axios.get(`/api/users/${params.userId}`)
.then(({ data: user }) => {
console.log('user', user);
this.setState({ user });
});
}
【问题讨论】:
-
我错过了顶部的这一行 ---componentDidMount() { const { match: { params } } = this.props; ---
标签: reactjs react-hooks