请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Check the render method of `TopicDetail`

老师您好,我这边遇到这个问题卡住了,不知道那里出了问题,

使用固定的话题 可以渲染出 详情页,但是也无法获取 

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
...

https://img1.sycdn.imooc.com//szimg/5b46ddab0001615313170767.jpg

但是 有正常的 api 请求,从 list 页面点击跳转到 detail 页面有正常的 api 请求

https://img1.sycdn.imooc.com//szimg/5b46df3b0001a76b13230443.jpg

但是刷新页面就会报错

https://img1.sycdn.imooc.com//szimg/5b46df9300016e8312950937.jpg

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>


源代码链接 https://gitee.com/custer_git/0702-yak-python-ide/commit/329a5f8b46082c648508cb6fe6d2700f61c4df7e#52248e4f8fd8a5c214cccdf3c4433a2cc930ce3a_1_1

正在回答 回答被采纳积分+3

1回答

Jokcy 2018-07-13 13:28:49

stores[storeName].toJson is not a function,你是不是又一个store的toJson方法没有写

0 回复 有任何疑惑可以回复我~
  • 提问者 慕侠3851047 #1
    老师toJson知道哪里出了问题,但是,详情页点开就报错,不知道为什么?麻烦老师了
    回复 有任何疑惑可以回复我~ 2018-07-13 13:39:11
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号