简体   繁体   English

在现有循环中显示 Websocket 响应数据时出现问题

[英]issue in showing Websocket response data in existing Loop

I need help in fixing a bug in my react app.我需要帮助来修复我的反应应用程序中的错误。

I am accessing data using websocket in react js, but when i show data in my loop based components it only returns value for single product but i want to show in loop based on multiple product and as per their correct values.我在 react js 中使用 websocket 访问数据,但是当我在基于循环的组件中显示数据时,它只返回单个产品的值,但我想基于多个产品并根据它们的正确值在循环中显示。

client.onmessage = (messageEvent) => {
  const msg = JSON.parse(messageEvent.data)
  const text = JSON.parse(msg.data)
  const auction = text.message
  const eventId = text.event
  const auctionUuid = auction.uuid 
  console.log(eventId) 
  console.log(text)
  console.log(auction)
  if (auctionUuid == this.props.uuid) {
    this.setState({
     auctionUuid: auctionUuid,
     auctionTitle: auctionTitle,
     totalBidAmount: auctionTotalBidAmount,
     userBidAmount: bidAmount,
     bidUsername: user,
     bidExpireDate: auctionBidExpireDate,
     webSocketAuctions: auction,
     counter: 9,
   }) 
    
  } else {
    console.log('uuid is not matched')
  }  
 } 

Hi you just build the table structure in back end.您好,您只是在后端构建表结构。 pass the message as single text type.Like this REF 1:将消息作为单个文本类型传递。像这样的REF 1:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM