I have a web application with the following flow:
You are in Investments screen, when rendering it makes an API request to some server and then the response comes as an array of investment objects. Then those objects are displayed as a List in the screen. The user is able to clic on one item of the list to get redirected to the Investment Details screen. The investment details screen has two components who need the information of the current investment to display some charts.
The redirect is handled by react-router using the ID of the investment as a URL parameter.
I was wondering which way could be the best to using the information of the current investment.
I mean. I can redirect the user from Investments to Investment Details and then use the URL param to make a request to the API to get the information related to that investment and then pass it down to the child components, or pass directly the information of the investment selected by the user from Investment to Investment Details as props and the same from Investment Details to its child components.
Am I getting into prop drilling?
Is another call to the API unnecessary in this case?
Thanks in advance.
question from:
https://stackoverflow.com/questions/65942050/best-way-to-handle-react-data-coming-from-backend 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…