【发布时间】:2020-09-13 20:11:03
【问题描述】:
我知道我们可以按照以下方式替换基于组件的类中的查询参数:
componentDidMount() {
const { location, replace } = this.props;
const queryParams = new URLSearchParams(location.search);
if (queryParams.has('error')) {
this.setError(
'There was a problem.'
);
queryParams.delete('error');
replace({
search: queryParams.toString(),
});
}
}
有没有办法在功能组件中使用反应挂钩?
【问题讨论】:
标签: reactjs react-router react-hooks