Variable Vs State, What is Better in React?

Hello Developers, Suppose I have 100 data from my API call and it needs to be rendered in the component. What is the better way to store and render it? Should I put the value in a useState variable or context API store? what is the better in react?

If that data is shared by multiple components, then a context makes sense. If the data is only for this one, useState.

Context in react is essentially a global state, available to any component under it to consume.

On the plus side, shared data! On the minus, shared dependency.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.