how to fetch data from firebase using expo react native app
Problem:
I am very new to react native and firebase stuff. I am making a train timetable system. There I have implemented a search function. This is how that component looks.
import React, Component from "react";
import
StyleSheet,
Text,
TextInput,
View,
TouchableOpacity,
Dimensions,
Picker,
ListView
from "react-native";
import
Ionicons,
Foundation,
Entypo,
MaterialCommunityIcons,
FontAwesome,
MaterialIcons
from "@expo/vector-icons";
import app from "../../config/db";
import Autocomplete from "react-native-autocomplete-input";
import addItem from '../../services/stationService';
const height, width = Dimensions.get("window");
const box_width = width / 2 + 40;
export default class TicketForm extends React.Component
constructor(props)
super(props);
this.state =
start: "",
end: "",
class: "",
isLoading:false
;
static navigationOptions =
title: "Tickets",
headerStyle:
backgroundColor: "#2b78fe"
,
headerTintColor: "#fff",
headerTitleStyle:
color: "#ffff"
;
search =()=>
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
render()
var ds = new ListView.DataSource( rowHasChanged: (r1, r2) => r1 !== r2 );
return (
<View style=styles.form>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="From"
onChangeText=start =>
this.setState( start: start );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="To"
onChangeText=end =>
this.setState( end: end );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.classSection>
<Picker
selectedValue=this.state.class
style= height: 50, width: box_width
onValueChange=(itemValue, itemIndex) =>
this.setState( class: itemValue )
>
<Picker.Item label="1 st Class" value="1" />
<Picker.Item label="2 nd Class" value="2" />
<Picker.Item label="3 rd Class" value="3" />
</Picker>
</View>
<View style=styles.buttonCoontainer>
<View style=styles.searchContainer>
<TouchableOpacity onPress=this.search>
<View style=styles.search>
<Text style=styles.searchText>Search</Text>
<Ionicons name="ios-search" size=30 color="#fff" />
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
const styles = StyleSheet.create(
form:
flex: 1,
borderWidth: 3,
borderRadius: 8,
borderColor: "#ffff",
backgroundColor: "#ffff",
marginTop: 15,
marginLeft: 15,
marginRight: 15,
marginBottom: 5,
paddingTop: 50,
paddingLeft: 20,
paddingRight: 20
,
input:
width: box_width,
flex: 1,
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 0,
backgroundColor: "#fff",
color: "#424242"
,
inputSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
borderColor: "#78909c",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
classSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#e9ebee",
borderColor: "#e9ebee",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
dateSection:
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10,
width: 335
,
inputIcon:
padding: 10
,
reverseContainer:
flexDirection: "row",
marginTop: 30
,
reverse:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#eff0f1"
,
reset:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: box_width / 4,
marginRight: 0,
backgroundColor: "#eff0f1"
,
reverseText:
marginTop: 3,
marginRight: 10
,
resetText:
marginTop: 3,
marginRight: 10
,
searchContainer:
flexDirection: "row",
marginTop: 30
,
search:
alignItems: "center",
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#2089dc",
borderRadius: 5,
width: box_width + 80,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: box_width / 2,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#2089dc"
,
searchText:
marginTop: 3,
marginRight: 10,
fontSize: 15,
fontWeight: "700",
color: "#ffff"
,
searchIcon:
fontWeight: "700"
);
When I hit the search button there it is giving me an error. Here I am specifying how I implemented the action inside the search function.
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
This is how I configure the firebase in my app and have imported it to my current component.
import Firebase from 'firebase';
let config =
apiKey: "My Key",
authDomain: "my domain",
databaseURL: "https://mytrain-5beba.firebaseio.com",
projectId: "mytrain-5beba",
storageBucket: "mytrain-5beba.appspot.com",
messagingSenderId: "305193513552"
;
let app = Firebase.initializeApp(config);
// export const db = app.database();
export default app;
This is how my database looks like in the console.
Can someone help me to query this database correctly from my react native app?. Thank you very much.
firebase react-native firebase-realtime-database
add a comment |
Problem:
I am very new to react native and firebase stuff. I am making a train timetable system. There I have implemented a search function. This is how that component looks.
import React, Component from "react";
import
StyleSheet,
Text,
TextInput,
View,
TouchableOpacity,
Dimensions,
Picker,
ListView
from "react-native";
import
Ionicons,
Foundation,
Entypo,
MaterialCommunityIcons,
FontAwesome,
MaterialIcons
from "@expo/vector-icons";
import app from "../../config/db";
import Autocomplete from "react-native-autocomplete-input";
import addItem from '../../services/stationService';
const height, width = Dimensions.get("window");
const box_width = width / 2 + 40;
export default class TicketForm extends React.Component
constructor(props)
super(props);
this.state =
start: "",
end: "",
class: "",
isLoading:false
;
static navigationOptions =
title: "Tickets",
headerStyle:
backgroundColor: "#2b78fe"
,
headerTintColor: "#fff",
headerTitleStyle:
color: "#ffff"
;
search =()=>
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
render()
var ds = new ListView.DataSource( rowHasChanged: (r1, r2) => r1 !== r2 );
return (
<View style=styles.form>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="From"
onChangeText=start =>
this.setState( start: start );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="To"
onChangeText=end =>
this.setState( end: end );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.classSection>
<Picker
selectedValue=this.state.class
style= height: 50, width: box_width
onValueChange=(itemValue, itemIndex) =>
this.setState( class: itemValue )
>
<Picker.Item label="1 st Class" value="1" />
<Picker.Item label="2 nd Class" value="2" />
<Picker.Item label="3 rd Class" value="3" />
</Picker>
</View>
<View style=styles.buttonCoontainer>
<View style=styles.searchContainer>
<TouchableOpacity onPress=this.search>
<View style=styles.search>
<Text style=styles.searchText>Search</Text>
<Ionicons name="ios-search" size=30 color="#fff" />
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
const styles = StyleSheet.create(
form:
flex: 1,
borderWidth: 3,
borderRadius: 8,
borderColor: "#ffff",
backgroundColor: "#ffff",
marginTop: 15,
marginLeft: 15,
marginRight: 15,
marginBottom: 5,
paddingTop: 50,
paddingLeft: 20,
paddingRight: 20
,
input:
width: box_width,
flex: 1,
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 0,
backgroundColor: "#fff",
color: "#424242"
,
inputSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
borderColor: "#78909c",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
classSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#e9ebee",
borderColor: "#e9ebee",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
dateSection:
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10,
width: 335
,
inputIcon:
padding: 10
,
reverseContainer:
flexDirection: "row",
marginTop: 30
,
reverse:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#eff0f1"
,
reset:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: box_width / 4,
marginRight: 0,
backgroundColor: "#eff0f1"
,
reverseText:
marginTop: 3,
marginRight: 10
,
resetText:
marginTop: 3,
marginRight: 10
,
searchContainer:
flexDirection: "row",
marginTop: 30
,
search:
alignItems: "center",
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#2089dc",
borderRadius: 5,
width: box_width + 80,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: box_width / 2,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#2089dc"
,
searchText:
marginTop: 3,
marginRight: 10,
fontSize: 15,
fontWeight: "700",
color: "#ffff"
,
searchIcon:
fontWeight: "700"
);
When I hit the search button there it is giving me an error. Here I am specifying how I implemented the action inside the search function.
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
This is how I configure the firebase in my app and have imported it to my current component.
import Firebase from 'firebase';
let config =
apiKey: "My Key",
authDomain: "my domain",
databaseURL: "https://mytrain-5beba.firebaseio.com",
projectId: "mytrain-5beba",
storageBucket: "mytrain-5beba.appspot.com",
messagingSenderId: "305193513552"
;
let app = Firebase.initializeApp(config);
// export const db = app.database();
export default app;
This is how my database looks like in the console.
Can someone help me to query this database correctly from my react native app?. Thank you very much.
firebase react-native firebase-realtime-database
add a comment |
Problem:
I am very new to react native and firebase stuff. I am making a train timetable system. There I have implemented a search function. This is how that component looks.
import React, Component from "react";
import
StyleSheet,
Text,
TextInput,
View,
TouchableOpacity,
Dimensions,
Picker,
ListView
from "react-native";
import
Ionicons,
Foundation,
Entypo,
MaterialCommunityIcons,
FontAwesome,
MaterialIcons
from "@expo/vector-icons";
import app from "../../config/db";
import Autocomplete from "react-native-autocomplete-input";
import addItem from '../../services/stationService';
const height, width = Dimensions.get("window");
const box_width = width / 2 + 40;
export default class TicketForm extends React.Component
constructor(props)
super(props);
this.state =
start: "",
end: "",
class: "",
isLoading:false
;
static navigationOptions =
title: "Tickets",
headerStyle:
backgroundColor: "#2b78fe"
,
headerTintColor: "#fff",
headerTitleStyle:
color: "#ffff"
;
search =()=>
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
render()
var ds = new ListView.DataSource( rowHasChanged: (r1, r2) => r1 !== r2 );
return (
<View style=styles.form>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="From"
onChangeText=start =>
this.setState( start: start );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="To"
onChangeText=end =>
this.setState( end: end );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.classSection>
<Picker
selectedValue=this.state.class
style= height: 50, width: box_width
onValueChange=(itemValue, itemIndex) =>
this.setState( class: itemValue )
>
<Picker.Item label="1 st Class" value="1" />
<Picker.Item label="2 nd Class" value="2" />
<Picker.Item label="3 rd Class" value="3" />
</Picker>
</View>
<View style=styles.buttonCoontainer>
<View style=styles.searchContainer>
<TouchableOpacity onPress=this.search>
<View style=styles.search>
<Text style=styles.searchText>Search</Text>
<Ionicons name="ios-search" size=30 color="#fff" />
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
const styles = StyleSheet.create(
form:
flex: 1,
borderWidth: 3,
borderRadius: 8,
borderColor: "#ffff",
backgroundColor: "#ffff",
marginTop: 15,
marginLeft: 15,
marginRight: 15,
marginBottom: 5,
paddingTop: 50,
paddingLeft: 20,
paddingRight: 20
,
input:
width: box_width,
flex: 1,
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 0,
backgroundColor: "#fff",
color: "#424242"
,
inputSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
borderColor: "#78909c",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
classSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#e9ebee",
borderColor: "#e9ebee",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
dateSection:
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10,
width: 335
,
inputIcon:
padding: 10
,
reverseContainer:
flexDirection: "row",
marginTop: 30
,
reverse:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#eff0f1"
,
reset:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: box_width / 4,
marginRight: 0,
backgroundColor: "#eff0f1"
,
reverseText:
marginTop: 3,
marginRight: 10
,
resetText:
marginTop: 3,
marginRight: 10
,
searchContainer:
flexDirection: "row",
marginTop: 30
,
search:
alignItems: "center",
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#2089dc",
borderRadius: 5,
width: box_width + 80,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: box_width / 2,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#2089dc"
,
searchText:
marginTop: 3,
marginRight: 10,
fontSize: 15,
fontWeight: "700",
color: "#ffff"
,
searchIcon:
fontWeight: "700"
);
When I hit the search button there it is giving me an error. Here I am specifying how I implemented the action inside the search function.
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
This is how I configure the firebase in my app and have imported it to my current component.
import Firebase from 'firebase';
let config =
apiKey: "My Key",
authDomain: "my domain",
databaseURL: "https://mytrain-5beba.firebaseio.com",
projectId: "mytrain-5beba",
storageBucket: "mytrain-5beba.appspot.com",
messagingSenderId: "305193513552"
;
let app = Firebase.initializeApp(config);
// export const db = app.database();
export default app;
This is how my database looks like in the console.
Can someone help me to query this database correctly from my react native app?. Thank you very much.
firebase react-native firebase-realtime-database
Problem:
I am very new to react native and firebase stuff. I am making a train timetable system. There I have implemented a search function. This is how that component looks.
import React, Component from "react";
import
StyleSheet,
Text,
TextInput,
View,
TouchableOpacity,
Dimensions,
Picker,
ListView
from "react-native";
import
Ionicons,
Foundation,
Entypo,
MaterialCommunityIcons,
FontAwesome,
MaterialIcons
from "@expo/vector-icons";
import app from "../../config/db";
import Autocomplete from "react-native-autocomplete-input";
import addItem from '../../services/stationService';
const height, width = Dimensions.get("window");
const box_width = width / 2 + 40;
export default class TicketForm extends React.Component
constructor(props)
super(props);
this.state =
start: "",
end: "",
class: "",
isLoading:false
;
static navigationOptions =
title: "Tickets",
headerStyle:
backgroundColor: "#2b78fe"
,
headerTintColor: "#fff",
headerTitleStyle:
color: "#ffff"
;
search =()=>
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
render()
var ds = new ListView.DataSource( rowHasChanged: (r1, r2) => r1 !== r2 );
return (
<View style=styles.form>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="From"
onChangeText=start =>
this.setState( start: start );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.inputSection>
<TextInput
style=styles.input
placeholder="To"
onChangeText=end =>
this.setState( end: end );
underlineColorAndroid="transparent"
/>
<MaterialCommunityIcons
style=styles.inputicon
name="backspace"
size=30
color="#42a5f5"
/>
</View>
<View style=styles.classSection>
<Picker
selectedValue=this.state.class
style= height: 50, width: box_width
onValueChange=(itemValue, itemIndex) =>
this.setState( class: itemValue )
>
<Picker.Item label="1 st Class" value="1" />
<Picker.Item label="2 nd Class" value="2" />
<Picker.Item label="3 rd Class" value="3" />
</Picker>
</View>
<View style=styles.buttonCoontainer>
<View style=styles.searchContainer>
<TouchableOpacity onPress=this.search>
<View style=styles.search>
<Text style=styles.searchText>Search</Text>
<Ionicons name="ios-search" size=30 color="#fff" />
</View>
</TouchableOpacity>
</View>
</View>
</View>
);
const styles = StyleSheet.create(
form:
flex: 1,
borderWidth: 3,
borderRadius: 8,
borderColor: "#ffff",
backgroundColor: "#ffff",
marginTop: 15,
marginLeft: 15,
marginRight: 15,
marginBottom: 5,
paddingTop: 50,
paddingLeft: 20,
paddingRight: 20
,
input:
width: box_width,
flex: 1,
paddingTop: 5,
paddingRight: 5,
paddingBottom: 5,
paddingLeft: 0,
backgroundColor: "#fff",
color: "#424242"
,
inputSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
borderColor: "#78909c",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
classSection:
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
backgroundColor: "#e9ebee",
borderColor: "#e9ebee",
borderWidth: 0.8,
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10
,
dateSection:
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
paddingLeft: 5,
paddingRight: 5,
marginTop: 10,
marginBottom: 10,
width: 335
,
inputIcon:
padding: 10
,
reverseContainer:
flexDirection: "row",
marginTop: 30
,
reverse:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#eff0f1"
,
reset:
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#eff0f1",
borderRadius: 5,
width: box_width / 2,
paddingTop: 3,
paddingBottom: 3,
paddingLeft: 20,
paddingRight: 10,
marginLeft: box_width / 4,
marginRight: 0,
backgroundColor: "#eff0f1"
,
reverseText:
marginTop: 3,
marginRight: 10
,
resetText:
marginTop: 3,
marginRight: 10
,
searchContainer:
flexDirection: "row",
marginTop: 30
,
search:
alignItems: "center",
flexDirection: "row",
borderWidth: 0.5,
borderColor: "#2089dc",
borderRadius: 5,
width: box_width + 80,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: box_width / 2,
paddingRight: 10,
marginLeft: 0,
marginRight: 20,
backgroundColor: "#2089dc"
,
searchText:
marginTop: 3,
marginRight: 10,
fontSize: 15,
fontWeight: "700",
color: "#ffff"
,
searchIcon:
fontWeight: "700"
);
When I hit the search button there it is giving me an error. Here I am specifying how I implemented the action inside the search function.
app.database().ref('/trains').on("value").then(snapshot=>
console.log(snapshot);
)
This is how I configure the firebase in my app and have imported it to my current component.
import Firebase from 'firebase';
let config =
apiKey: "My Key",
authDomain: "my domain",
databaseURL: "https://mytrain-5beba.firebaseio.com",
projectId: "mytrain-5beba",
storageBucket: "mytrain-5beba.appspot.com",
messagingSenderId: "305193513552"
;
let app = Firebase.initializeApp(config);
// export const db = app.database();
export default app;
This is how my database looks like in the console.
Can someone help me to query this database correctly from my react native app?. Thank you very much.
firebase react-native firebase-realtime-database
firebase react-native firebase-realtime-database
edited Nov 14 '18 at 2:52
dwp
asked Nov 13 '18 at 22:17
dwpdwp
12210
12210
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can try something like this:
.database()
.ref('/trains/')
.on('value', snapshot =>
const trains = snapshot.val();
console.warn(trains);
);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290354%2fhow-to-fetch-data-from-firebase-using-expo-react-native-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try something like this:
.database()
.ref('/trains/')
.on('value', snapshot =>
const trains = snapshot.val();
console.warn(trains);
);
add a comment |
You can try something like this:
.database()
.ref('/trains/')
.on('value', snapshot =>
const trains = snapshot.val();
console.warn(trains);
);
add a comment |
You can try something like this:
.database()
.ref('/trains/')
.on('value', snapshot =>
const trains = snapshot.val();
console.warn(trains);
);
You can try something like this:
.database()
.ref('/trains/')
.on('value', snapshot =>
const trains = snapshot.val();
console.warn(trains);
);
edited Nov 14 '18 at 0:31
answered Nov 14 '18 at 0:04
Sergio ClementeSergio Clemente
10115
10115
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290354%2fhow-to-fetch-data-from-firebase-using-expo-react-native-app%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown