在另一个组件中重新渲染一个组件 [英] Re-rendering a Component Within another Component
问题描述
所以我有一个名为TicketView
的组件,该组件在我的另一个组件中使用,该组件只是称为Table
. TicketView会在表格中初始化,如下所示:
So I have a component called TicketView
that is used within another component of mine, which is just called Table
. TicketView is initialized in the table just like this:
<TableRow key={index}>
...
<TableRowColumn style={{width: '80px'}}><TicketView id={row.TicketID} /></TableRowColumn>
</TableRow>
<TableRow key={index}>
...
<TableRowColumn style={{width: '80px'}}><TicketView id={row.TicketID} /></TableRowColumn>
</TableRow>
使用Axios
传播TableRow
数据,我在表上刷新了5秒钟,以便使用GET
方法每5秒刷新一次表数据.但是,在刷新过程中,所有输入的数据都会更改,但是TicketView
组件所需的数据不会更改.我不确定如何从Table
刷新中完全刷新TicketView
组件.进行此操作的最佳方法是什么?
The TableRow
data is propogated using Axios
, and I have a 5 second refresh on the table to use a GET
method to refresh the table data every 5 seconds. However, during the refresh, all the inputted data is changed, but the data I need for the TicketView
component does not change. I'm unsure how to exactly refresh the TicketView
component from the Table
refresh. What is the best way to undergo this?
推荐答案
所以对我而言,最好的方法是将从GET方法获得的新数据作为道具传递给TicketView组件,并做出反应以呈现新值.
So the best way according to me is pass the new data that arrives from your GET method as props to TicketView component and react will render the new values.
这篇关于在另一个组件中重新渲染一个组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!