DEV Community

Discussion on: Beginner's experience with React - a shout for feedback

Collapse
 
sergiodxa profile image
Sergio Daniel Xalambrí

My main question is what is the right way to decide what should be its own component and shouldn't be?
Start everything in the same component until you feel the need to extract something, this could happen if you need to make it reusable, it’s too big and you would prefer to have them in another file or just because it could be a good split point of certain logic.

Collapse
 
devshehata profile image
Mahmoud Shehata

The thing is If you need to process API data for example and have to make a couple of functions to do that. Would be better to have the processing in one component and the display in another?

Cus for this project I was thinking to have ONE component to process both current weather AND forecast and then return the values back and then I'd decide which one to display and which one to pass to which component. I think that is a very logical way to think about it. But then with the one way data flow in React not sure if it's possible.

You could Imagine one parent search Component -> API engine -> Display component
But those display component need to send back data to API engine again if the user wants to update the request or something.

What do you think?