【发布时间】:2016-09-03 10:23:09
【问题描述】:
我正在使用此代码来创建路由 redux 路由器
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, combineReducers } from 'redux'
import { Provider } from 'react-redux'
import { Router, Route, browserHistory } from 'react-router'
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
import Calendar from '../calendar/calendar'
import Cards from '../cards/cards'
const history = syncHistoryWithStore(browserHistory)
const App= () => {
return <div>
<h2>start</h2>
<a href="/calendar">calendar</a>
<a href="/cards">cards</a>
</div>
}
const store = createStore(
combineReducers({
routing: routerReducer
})
)
ReactDOM.render(
<Provider store={store}>
{ /* Tell the Router to use our enhanced history */ }
<Router history={history}>
<Route path="/" component={App}>
<Route path="calendar" component={Calendar}/>
<Route path="cards" component={Cards}/>
</Route>
</Router>
</Provider>,
document.getElementById('mount')
)
我收到了这个错误
“未捕获的类型错误:无法读取未定义的属性 'getState'”
我正在尝试在 app redux 上实现路由器 redux 谢谢
卡洛斯·维埃拉
【问题讨论】:
-
我正在关注这个链接github.com/reactjs/redux
-
你必须在你调用
getState的地方显示代码 -
我把状态放在哪里?我只是按照github.com/reactjs/react-router-redux下链接的代码行
-
你能告诉我们你创建商店的代码吗?
-
我正在关注上面的网站,并使用 const store = createStore( combineReducers({ routing: routerReducer }) ) 创建商店
标签: reactjs redux redux-router