Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What problem does `react-redux-firebase` solve?

I'm new to all of these technologies, but as far as I understand it, you can use React Native with Redux and Firebase without react-redux-firebase. You could just use

  • react
  • react-native
  • redux
  • react-redux
  • react-native-firebase

Then you load data from Firebase (e.g. Firestore) and put the data in a reducer so it gets merged into the redux store.

Why do I need react-redux-firebase? What problem does it solve?

I have tried its docs, but they seem to be written for someone who is already familiar with its goals. They do not really explain, and when reading the examples, I do not understand why I specifically need react-redux-firebase instead of the setup listed above.

like image 322
cheesus Avatar asked Dec 14 '25 13:12

cheesus


1 Answers

Firebase is on your state, listen to it an modify it, it will change your Firebase database. After the data on the database is changed the components listening will change as well.

This will create an item in the database

    updateTodo: props => () => {
      return firebase.update(`todos/${params.todoId}`, { done: !todo.isDone })
    }

So any component listening to that node will get updated:

  connect((state) => ({
    todos: state.firebase.data.todos,
    // profile: state.firebase.profile // load profile
  }))

It solves the problem of having multiple sources of truth, your Firebase database is your only source of truth, otherwise, you change your local data and then you update the data online and then if it works nothing else but if it fails you have to update the local data again

like image 165
cutiko Avatar answered Dec 16 '25 23:12

cutiko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!