I'm wondering whether it's possible to have changes in a Firestore DB automatically reflected in a React app. That is -- if I have the correct terminology -- whether I can bind the two together, with the Firestore DB acting as a model and the React app acting as the view.
Failing using something like WebSockets, I can't think of a way that doesn't involve some sort of polling.
I did come across react-redux-firebase
, which allows to connect Firestore to Redux. But on a first glance, I can't tell whether this means that changes in Firestore are automatically transmitted to Redux, that is whether react-redux-firebase
does some sort of polling, etc, on its own. Or whether you have to query the Firestore data yourself.
(Full disclosure: reflecting changes in React from a Firestore DB is a small part of a coding challenge I'm working on, but I figure it's fair game to ask on Stack Overflow to see if I'm heading down a viable path, since this is what I'd do in 'real life' in any case. I suspect I'll need to do the polling myself, but wanted to see if there were any library, like react-redux-firebase
, that would 'push' the data from Firestore to React/Redux automatically).
question from:
https://stackoverflow.com/questions/65649232/is-it-possible-to-get-automatic-updating-binding-from-firestore-to-a-react-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…