Home > Enterprise >  how to update redux data when a field is updated in database (React-Native | NodeJS)
how to update redux data when a field is updated in database (React-Native | NodeJS)

Time:10-06

I have a mongoDB,a node server, and a react-native app. What I want is when a certain field update in my mongoDB document to trigger a redux change in my react-native app. Do anyone have an idea how to achieve this ?

CodePudding user response:

I assume your react app would not have a direct connection with the mongoDb (and it should be like this). Now, whenever something updates in mongoDb, it must be from your node server. Node server can notify about the change to your react frontend in many ways, like:

  1. Via websockets
  2. Via push notifications / cloud messaging
  3. Server sent events
  4. Polling the server from your frontend app

Whenever your react app is notified for a certain event, you then trigger a change in your redux state

  • Related