TanStackT
TanStack2y ago
9 replies
foolish-indigo

Many children subscribers vs passing from parent

Is there any performance considerations when you have many components that subscribe to a
useQuery


Is it better to do this

const {data} = useQuery(...)

return <div>
  <Child data={data} />
  <Child data={data} />
  <Child data={data} />
  <Child data={data} />
  ...
  <Child data={data} />
  <Child data={data} />
</div>


Or just let the Child component subscribe to the
useQuery
itself

const Child = () => {
const {data} = useQuery(...)

return ...
}

const Parent = () => {
  return <div>
    <Child />
    <Child />
    <Child  />
    <Child  />
    ...
    <Child />
    <Child/>
  </div> 
}
Was this page helpful?