访问storage.get返回的值

时间:2019-05-20 10:59:30

标签: reactjs aws-amplify

我正在使用connect组件执行查询。这是代码

<Connect
        query={graphqlOperation(listRecordss)}
        subscription={graphqlOperation(onCreateRecords)}
        onSubscriptionMsg={onNewRecord}
    >

        {({data, loading, error}) => {
            if (loading) return "Loading"
            if (error) return "Error"
            const ListRecord = data.listRecordss.items
            console.log('ListRecord', ListRecord)
            data.listRecordss.items.map(image => (
            Storage.get(image.audio.key)
              .then(result =>{ console.log("Storageb", result)
               const Me = result
               this.state.voice=Me
              })
              .catch(err => console.log(err))
            ))

            return <div><MUIDataTable
            title={"Leistungen"}
            data={ ListRecord.map((rest) => (
              [rest.createdAt, rest.record, 
                <Audio voice={this.state.voice} a={rest.audio.key}/>, 


            <Image p={rest.file.key}/>,


                rest.arzt, rest.patient]
           ))}
            columns={columns}
            options={options}
            />
            </div>

        }}
    </Connect>

我想访问Storage.get<Audio>返回的结果,但是该值未传递下来。我还尝试在storage.get中使用this.setState({Audio: Me}),但这使我陷入无限循环。因此,所有人都知道我如何将结果从storage.get传递到<Audio>。非常感谢!

0 个答案:

没有答案