Check the render method of `TopicDetail`
来源:4-7 话题详情页

慕侠3851047
2018-07-12
老师您好,我这边遇到这个问题卡住了,不知道那里出了问题,
使用固定的话题 可以渲染出 详情页,但是也无法获取
topicStore: TopicStore{…}
# !/client/views/topic-detail/index.jsx ... render() { const { classes, } = this.props // const id = this.getTopicId() // 通过react-router生成的match对象获取url的params参数 // const topic = this.props.topicStore.detailMap[id] const topic = this.props.topicStore.topics[1] if (!topic) { // topic 不存在加载 loading ...
但是 有正常的 api 请求,从 list 页面点击跳转到 detail 页面有正常的 api 请求
但是刷新页面就会报错
type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `TopicDetail`. in TopicDetail (created by inject-TopicDetail) in inject-TopicDetail (created by WithStyles(inject-TopicDetail)) in WithStyles(inject-TopicDetail) (created by Route) in Route (created by _default) in _default (created by App) in App (created by Main) in Main in MuiThemeProvider in Router (created by BrowserRouter) in BrowserRouter in Provider in AppContainer
The above error occurred in the <section> component: in section (created by TopicDetail) in div (created by Paper) in Paper (created by WithStyles(Paper)) in WithStyles(Paper) (created by Container) in Container (created by WithStyles(Container)) in WithStyles(Container) (created by TopicDetail) in TopicDetail (created by inject-TopicDetail) in inject-TopicDetail (created by WithStyles(inject-TopicDetail)) in WithStyles(inject-TopicDetail) (created by Route) in Route (created by _default) in _default (created by App) in App (created by Main) in Main in MuiThemeProvider in Router (created by BrowserRouter) in BrowserRouter in Provider in AppContainer React will try to recreate this component tree from scratch using the error boundary you provided, AppContainer.
运行服务端 npm run dev:server 跳转到 detail 页面也会报错
TypeError: stores[storeName].toJson is not a function at Object.keys.reduce (/Users/tianxiaoqiang/Life/git-osc/IDE/0702-yak-python-ide/server/utils/server-render.js:14:43) at Array.reduce (<anonymous>) at getStoreState (/Users/tianxiaoqiang/Life/git-osc/IDE/0702-yak-python-ide/server/utils/server-render.js:13:30) at bootstrapper.then (/Users/tianxiaoqiang/Life/git-osc/IDE/0702-yak-python-ide/server/utils/server-render.js:46:21) at <anonymous>
写回答
1回答
-
Jokcy
2018-07-13
stores[storeName].toJson is not a function,你是不是又一个store的toJson方法没有写
012018-07-13
相似问题