Get image from firebase storage react native and reactjs
Display image from firebase storage web
Display images from firebase storage in html img tags
import React,{Component} from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import { Card,Button } from 'react-bootstrap';
import firebase,{storage} from 'firebase';
const firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxx",
databaseURL: "xxxxxxxxxxxx",
projectId: "xxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxxxxxxxxxxxx",
appId: "xxxxxxxxxxxxx",
measurementId: "xxxxxxx"
};
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
var imageSo;
export default class ViewProductForDashboard extends Component
{
constructor(props) {
super(props);
this.state = {
image: null,
url: '',
}
}
handleGetUrlImage = () => {
var storage = firebase.storage();
storage.ref('images/').child("imag1").getDownloadURL().then(url => {
console.log(url);
this.setState({image:url});
imageSo=url;
this.render();
});
}
render()
{
return(
<div className="container">
<h1>ViewProductForDashboard</h1>
<img src={imageSo} className="img-rounded" alt="Cinque Terre" width="250" height="150"></img>
<button type="submit" onClick={this.handleGetUrlImage} className="btn btn-primary">View Product</button>
</div>
);
}
}