title: How to increment Firebase Realtime database data values by one in React Native?
body: <p>I have a Firebase Realtime database like this.</p>
  
  <p><code>myRoot
    |--- mykey1
    |     |---myValue: 1
    |
    |--- mykey2
    |     |---myValue: 0
    |
    |--- mykey3
          |---myValue: 2</code></p>
  
  <p>I need to increment all these values by one and get the following output.</p>
  
  <p><code>myRoot
    |--- mykey1
    |     |---myValue: 2
    |
    |--- mykey2
    |     |---myValue: 1
    |
    |--- mykey3
          |---myValue: 3</code></p>
  
  <p>How I can do this using a loop? Or, what is the best way to do this in React Native?</p>
  
  <p>The actual thing what I want is this. Let's think, I have a home screen. It has a button called "List values". When I clicked, I navigate to the next page (Stack navigator) and there, it displays the values of myKey1, myKey2, myKey3. It is a flatlist. Let's think there is a button called "Increment values" in that second sreen. When I pressed it, I want to increment the values and navigate back to the home screen.</p>
  
  <p>I've tried something like this.</p>
  
  <pre><code>let arr = ['myKey1' , 'myKey2' , 'myKey3']
  
  try {
    for(let i=0; i&lt;arr.length; i++) {
       let ref = firebase.database().ref(myRoot).child(arr[i]);
       ref.transaction( function(myValue) {
          return (myValue || 0) + 1;
       })
    }
    this.props.navigation.goBack();
  }
  catch(error) {
    console.log(error));
  }
  </code></pre>
  
  <p>It changes the values in the database as I expect. But, it gives the following yellow warning after execution.</p>
  
  <blockquote>
    <p>Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method</p>
  </blockquote>
  
  <p>This is a sample model to explain what I need.</p>
  
  <p>How to solve this problem?</p>