路由更改但没有使用axios请求刷新数据

时间:2018-05-10 15:32:26

标签: reactjs react-router react-redux

我读过关于处理被阻止的更新但没有运气的信息:

<Provider store={createStoreWithMiddleware(reducers)}>
        <Router>
            <Route component={App}/>
        </Router>
    </Provider>

和app.js:

class App extends Component {
  render() {
    return (
        <div>
            <Switch>
                <Route exact path="/" component={Home}/>

                {/*<Route exact path="/Blog" render={props => (
                        <Redirect to={`/Blog/page-${props.match.params.id}`}/>
                    )}/>*/}


                <Redirect exact from="/blog" push to="/blog/page=1"/>
                <Route path="/blog/page=:p" component={BlogPage}/>
                <Route path="/post/:id" component={BlogPageInfoPage}/>
                <Route path="/blog/categories/:id/page=:p" component={FilterCategoryPage}/>
                <Route path="/blog/search/:term/page=:p" component={SearchCategoryPage}/>
                <Route path="/cart" component={Cart}/>
                <Route path="/products" component={Products}/>
                <Route path="/product/:id" component={ProductPage}/>
                <Route path="/supplier" component={SupplierHomePage}/>
                <Route path="/register" component={RegisterPage}/>
                <Route path="/*" component={NotFound}/>
            </Switch>
            <Footer/>
        </div>
    );
  }
}

export default App;

点击子组件链接:

<Link to={`/blog/categories/${cat.id}/page=1`}><span
                        className="fs-11 text-muted float-left"></span>{cat.title}</Link>

我知道第一次改变位置的变化,但第二次没有, 和HOC withRouter的父页面:

function mapStateToProps(state) {
    return {posts: state.posts, blogPagination: state.blogPagination};
}

export default withRouter(connect(mapStateToProps, {fetchSpecificCats, fetchBlogCatPagination})(FilterCategory));

如果您需要更多代码来了解发生了什么,请告诉我

0 个答案:

没有答案