fus-marcom / bulletin-react

React/Redux version of the University Bulletin
MIT License
42 stars 18 forks source link

TypeError: Cannot read property 'edges' of undefined #42

Closed isaiahnixon closed 7 years ago

isaiahnixon commented 7 years ago

I am using a Windows 10 machine. Using an administrator Git Bash terminal I cloned the repo. Then using the Windows "Node.js Command Prompt" I ran the npm install and start commands. The Installation went fine, but when the application launched on port 3000 in Google Chrome I immediately received this error:

TypeError: Cannot read property 'edges' of undefined
displayCategories
C:/Users/windows_user/node.js/bulletin-react/src/components/Layout/drawer.js:26
  23 |     <ListItemText secondary={`All`} />
  24 |   </ListItem>
  25 | </Link>
> 26 | {data.categories.edges.map(category => (
  27 |   <Link
  28 |     key={category.node.id}
  29 |     to={`/category/${category.node.slug}`}
View compiled
SideComponent.render
C:/Users/windows_user/node.js/bulletin-react/src/components/Layout/drawer.js:80
  77 | </Link>
  78 | <Divider />
  79 | <ListSubheader>Categories</ListSubheader>
> 80 | {displayCategories(this.props)}
  81 | <Divider />
  82 | <ListItem button>
  83 |   <ListItemIcon>
View compiled
▶ 23 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
pantharshit00 commented 7 years ago

just add a short circuit check.

{data.categories && .....}

i have implemented that in my latest pr.

The error rose as you internet might be not so good.or apiserver is not started. make sure to use node 8.

SebastianCApostolescu commented 7 years ago

Weird. I can't replicate the issue.

pantharshit00 commented 7 years ago

@SebastianCApostolescu You internet would be fine. We just need to add a check for the data

isaiahnixon commented 7 years ago

@pantharshit00 That solved it, thanks! I also had to add a check to line 8 of ListView.js since it references edges as well.