#React CONTEXT / Adding items to Cart

2 messages · Page 1 of 1 (latest)

hybrid grail
#

Hey,
No, you don't need to add all data inside the context file. You can just track cart items inside it with the help of addToCart and removeFromCart functions and use those functions where ever you need. If it does not make sense could you please share your code so I can have an idea what might be creating the confusion?

sleek plaza
#

If you have your pre-defined data in a JSON you can "pretend" that comes from a server since it is pretty much hard coded and use it in your project. You don't need to store your static data in a context at all, you will be able to access that static file from anywhere in the application and that's not a problem at all.