[英]No location change upon connected-react-router push() from within the react-redux connect()
Dispatching the push action which was defined in mergeProps parameter of the react-redux connect() dispatches redux action but does not trigger url page change. 分派react-redux connect()的mergeProps参数中定义的push操作会分派redux操作,但不会触发url页面更改。 I also wrapped the withRouter around the redux container but no seems to help.
我也将withRouter包装在redux容器周围,但似乎无济于事。
//connect.js
import { Component } from './Component';
import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import { push } from 'connected-react-router';
import { onFetch, onUpdate } from '../action-creators';
export default withRouter(connect(state => state,
{
onFetch,
onUpdate,
push
},
( state, actions ) => ({
...state,
onFetch: actions.onFetch,
onUpdate: index => {
actions.onUpdate( index );
actions.push( `/${ index }` );
}
})
)( Component ));
What can I do to also trigger actual page update along with the LOCATION_CNANGE redux action using the create-react-router package? 如何使用create-react-router包触发实际的页面更新以及LOCATION_CNANGE redux操作? At this point, only the connected-react-router middleware and the redux store are being updated but no actual page change.
此时,仅更新了连接的反应路由器中间件和redux存储,但没有实际的页面更改。
Fixed it by modifying a redirect 'from' prop. 通过修改重定向“来自”道具修复了该问题。
Root cause: a redirect was placed at the end of the switch child routes list as a catchall rerouting to the main page. 根本原因:重定向位于交换子路由列表的末尾,作为重新路由到主页的综合包。 However, all requests (including valid ones except '/') went to the catchall redirect and were rerouted to main page.
但是,所有请求(包括“ /”以外的有效请求)都转到了catchall重定向并重新路由到了主页。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.