I am working on React native. I am getting data to and from the server. That data doesn't have key isFavorite, so I want to add isFavorite=true (or false) to all items.
If the item is present in sqlite, I want to set isFavorite = true (OR false) if the item is preset in Sqlite DB Table. I just want to set the isFavorite key for items in the array and set this array to the state domains.
The code below executes fine, but it executes after this.setState({ domains: arr })1 and  isFavorite` is not applied to the state domains.
    setFavorites() {
        let arr = this.state.domains.map((item, index) => {        
            db.transaction((tx) => {
                try {
                    tx.executeSql(
                        'SELECT * FROM table_favorites WHERE id=' + item.product_id, [],
                        (tx, results) => {
                            var len = results.rows.length;
                            if (len > 0) {
                                item.isFavorite = true
                                console.log("YES:", item.product_id)
                            } else {
                                item.isFavorite = 
                                console.log("NO:", item.product_id)
                            }
                        }
                    );
                    
                } catch (error) {
                }
            });
            return { ...item }
        })
        this.setState({ domains: arr })
            console.log("ARRA:", arr);
    }
   
 
    