question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'items' of undefined inside API react Connect component

See original GitHub issue

** Which Category is your question related to? ** API

** What AWS Services are you utilizing? ** API (GraphQL AppSync) Auth

** Provide additional details e.g. code snippets ** Error: screen shot 2018-09-05 at 4 22 07 pm

My App.js:

import React, { Component } from 'react';
import './App.css';
import Amplify, { graphqlOperation }  from "aws-amplify";
import { Connect } from "aws-amplify-react";
import awsmobile from './aws-exports';
Amplify.configure(awsmobile)

class App extends Component {
  render() {
    const ListView = ({ companies }) => (
      <div>
        <h3>All companies</h3>
        <ul>
            {companies.map(company => <li key={company.id}>{company.name} ({company.id})</li>)}
        </ul>
      </div>
    );

    const ListCompanys = `query ListCompanys {
      listCompanys {
        items {
          id
          name
        }
      }
    }`;

    return (
      <div className="App">
        <Connect query={graphqlOperation(ListCompanys)}>
          {({ data: { listCompanys } }) => (
              <ListView companies={listCompanys.items} />
          )}
        </Connect>
      </div>
    );
  }
}

export default App;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lazydragoncommented, Sep 5, 2018

I am having similar issues, the same query succeed with API.graphql call directly, but fail with Connect.

0reactions
github-actions[bot]commented, Jun 13, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS - cannot read property 'items' of undefined
When I try to console.log(this.state.items) in the addItem method, I get this error. Uncaught TypeError: Cannot ...
Read more >
How to Read React Errors (fix 'Cannot read property of ...
TypeError is the kind of error. There are a handful of built-in error types. · Cannot read property means the code was trying...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Cannot read property 'reduce' of undefined in react-Reactjs
Coding example for the question TypeError: Cannot read property 'reduce' of undefined in react-Reactjs.
Read more >
Can Not Read Properties of Undefined Reading Map in React ...
If you are looking at can not read properties of undefined reading map in react js error or map function is not displaying...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found