react-redux-boilerplate
react-redux-boilerplate copied to clipboard
Redirect does not update Component
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.
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, i tried your fix and it doesn't work. The url change but no render of the switch route component.
Redirect to login, login component does not render,I also encountered the same problem, how can I solve it?