【问题标题】:How to use getquery with amplify <Connect/> component in React如何在 React 中使用 getquery 和放大 <Connect/> 组件
【发布时间】:2019-05-24 11:10:54
【问题描述】:

我一直在尝试将 getquery 与 react 一起使用,但我无法让它工作。下面是我整理的代码

const input = {
        id: this.props.Id
      };

        return (
                  <div>
                    <Connect
                            query={graphqlOperation(getRecords, input)}
                            subscription={graphqlOperation(onCreateRecords)}
                            onSubscriptionMsg={onNewRecord}
                          >
                            {({data, loading, error}) => {
                                    if (loading) return "Loading"
                                    if (error) return "Error"
                                    const ListRecord = data.getRecords
                                    console.log('ListRecord', ListRecord)                  
                                    //console.log returns undefined
                                    return <div>...
                                      </div>  
                            }}
                      </Connect>
                    </div>

Deos 有人知道我做错了什么吗?谢谢!

【问题讨论】:

    标签: reactjs amazon-dynamodb aws-amplify aws-appsync


    【解决方案1】:

    仅凭您发布的内容很难说。 “数据”对象中是否有任何其他信息?

    另外,你有没有尝试过:

    query={graphqlOperation(getRecords,  {input})}
    

    【讨论】:

    • nope 仍然返回未定义。你需要什么来帮助我,因为这几乎是整个班级谢谢
    猜你喜欢
    • 2020-02-25
    • 2021-10-21
    • 2016-05-28
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    • 2013-01-10
    • 2017-04-10
    相关资源
    最近更新 更多