Re-rendering a Component Within another Component

江枫思渺然 提交于 2019-12-25 08:39:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!