I am just starting to learn ReactJS. I would like to know which is better given the scenario: The parent component makes a GET
request to some server, returning a JSON
object. I want to pass these attributes to a child component. However, not all of the JSON attributes can be rendered directly in the child component's view (I.e I cannot use props.XXX
in the child component). Either the parent component runs the preprocessing code to package the data nicely for the child component, or the child component does the preprocessing before it renders it's own view.
Should the parent or the child component run the preprocessing code ?
UseEffect
hook to retrieve the data is run after therender
method in parent component.