Skip to content
Advertisement

How do I pass JSON data retrieved with SocketIO to my Routes in React?

I need to get the variables in my routes to update from the JSON data and also sometimes emit data, but I haven’t figured out how to pass response to my Routes for accessing.

App.js file where the JSON is retrieved:

JavaScript

Routes.js where the Routes are created:

JavaScript
  1. I get the JSON data from my Flask backend using SocketIO
  2. JSON data is saved in response (I believe)
  3. I then want the JSON data to be accessible by each Route in Routes (the pages).

Any help is appreciated, thank you.

Advertisement

Answer

Pass props along:

App.js:

JavaScript

Routes.js:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement