<HashRouter> <main> <Switch> <Route exact path="/" component={IndexPage} /> <Route path="/login" component={Login} /> <Route path="/album" component={Album} /> </Switch> </main> </HashRouter>如題,定義了一個名為album的route,然后在此路由的component的componentDidMount里,獲取到this.props.location.search,即"?id=1",通過異步獲取數(shù)據(jù)然后更新store,觸發(fā)此組件的re-render,這個組件里面有個鏈接為"/album?id=2"的Link,由于只改變了查詢字段,沒有觸及pathname的更新,所以此鏈接能點,history也會更新,componentDidUpdate也能看到props.location.search改變,但是store并不更新,所以組件也不會re-render...所以我該在什么地方更新store呢?
React router 4 帶參數(shù)的路由,從"/album?id=1"訪問"/album?id=2
收到一只叮咚
2019-02-15 19:15:29