react-redux-boilerplate icon indicating copy to clipboard operation
react-redux-boilerplate copied to clipboard

Redirect does not update Component

Open xescuder opened this issue 6 years ago • 3 comments

I've tried to use push history and Redirect but the effect is always the same, location is changed on browser, but expected Component is not rendered (render method of previous url is called instead). I've tried to use withRouter in compose but also no effect.

App.js: <Route path="/equities/:id" component={EquityPage}/>

HomePage: if (toEquity === true) { let whereTo = '/equities/' + selectedSuggestion; return <Redirect push to={whereTo}/> }

EquityPage is not rendered and not even his methods (componentDidMount, componentWillReceiveProps, ...)

Thanks in advance.

xescuder avatar Aug 10 '18 17:08 xescuder

I think I've found the solution! If anyone is interested create at 'app.js', create a wrapper from App using withRouter.

import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import {push} from 'react-router-redux';

const AppComposed = withRouter(connect(null, {push})(App));

ReactDOM.render( <Provider store={store}> {/* <LanguageProvider messages={messages}> /} <ConnectedRouter history={history}> <AppComposed/> </ConnectedRouter> {/ </LanguageProvider> */} </Provider>, MOUNT_NODE

xescuder avatar Aug 10 '18 18:08 xescuder

@xescuder, i tried your fix and it doesn't work. The url change but no render of the switch route component.

ray-delossantos avatar Nov 13 '18 05:11 ray-delossantos

Redirect to login, login component does not render,I also encountered the same problem, how can I solve it? image

zhenujt avatar Feb 20 '19 08:02 zhenujt