在我的应用程序中导航时,作为道具的数据未按预期更新。但是,如果我重新加载页面,数据会按预期更新。
我不确定为什么会这样?我的应用程序中的其他页面上没有此问题?解决方案是强制重新加载页面吗?
这是我的react-router代码:
/* Packages */
import React from 'react';
import ReactDOM from 'react-dom';
import {Route, Router, IndexRoute, browserHistory} from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import { Provider } from 'react-redux';
/* Import Data */
import store from './store'
/* Containers */
import App from './js/containers/App';
import Home from './js/containers/Home';
import HowWeDoIt from './js/containers/HowWeDoIt';
import AdProducts from './js/containers/AdProducts';
import AdProduct from './js/containers/AdProduct';
import News from './js/containers/News';
import Showcase from './js/containers/Showcase';
/* Styles */
import './index.css';
const app = document.getElementById('app');
const history = syncHistoryWithStore(browserHistory, store);
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App} history={history}>
<Route path="approach" component={HowWeDoIt} history={history} />
<Route path="products" component={AdProducts} history={history} />
<Route path="products/:product" component={AdProduct} history={history} />
<Route path="news" component={News} history={history} />
<Route path="showcase" component={Showcase} history={history} />
<IndexRoute component={Home} />
</Route>
</Router>
</Provider>,
app);