I am new in ReactJs. As I understand React context API used for sharing data between components to avoid pass data with props repeatedly in nested components. But I can do it with a simple separate JS file. In a JS file I can simply declare an object to keep data and have some functions to update or get the stored data in all components.
What is the main difference between Context API and a JS file to store user data? Where and when should I use React Context API?