问题
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>
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?
回答1:
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.
来源:https://stackoverflow.com/questions/43945879/re-rendering-a-component-within-another-component