having a bit of trouble. I should start by saying I'm really new to react native so hopefully it's not something foolish I've missed. I'm using firebase to store image uri's but when I try to pass them in render from my function it gives me the {_40:0,_65:0,_55:null,_72:null} output but in the function, it seems to get the uri just fine so it seems to be something with passing it back.
I've tried using AsyncImage (using the sunglass dog example: https://www.npmjs.com/package/react-native-async-image-animated ) but it just sits forever loading I think and output in render remains the same.
export class PinImgScreen extends React.Component {
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
}}>
{console.log(get_firebaseImgTest(targetinMem, 1))}
<AsyncImage
style={{
borderRadius: 50,
height: 100,
width: 100,
}}
source={{
uri: get_firebaseImgTest(targetinMem, 1),
}}
placeholderColor="#b3e5fc"
/>
</View>
);
}
}
function get_firebaseImgTest(userId, num) {
return new Promise(function(resolve, reject) {
setTimeout(() => {
firebase
.database()
.ref('Info1/' + userId + '/imgInfo' + num)
.on('value', snapshot => {
console.log('GIBS ' + snapshot.val().imgInfo);
resolve(snapshot.val().imgInfo);
reject('https://www.gstatic.com/webp/gallery/1.jpg');
});
}, 200);
});
}
OutPut:
1: {_40:0,_65:0,_55:null,_72:null}