Reputation: 11
I am trying to show a spinner on press of button in react-native, native-base after username is entered. It is not working. Here are my steps and code:
Steps:
if loading true render spinner else load other screen.
constructor(props) {
super(props);
this.state = {
loading: true,
}
handleLoginPressed = async () => {
//some code
let resp = await tryAsk(this.state.sampleQuestion, this.state.username);
this.setState({
loading: false
});
}
render() {
if (this.state.fontsAreLoaded == true) {
if (this.state.isLoggedIn === true) {
if (this.state.loading === true){
<View><Spinner /></View>
}else{
return (
<Somescreen/>
);
}
}
Upvotes: 1
Views: 4231
Reputation: 29
you forget return
constructor(props) {
super(props);
this.state = {
loading: true,
}
handleLoginPressed = async () => {
//some code
let resp = await tryAsk(this.state.sampleQuestion, this.state.username);
this.setState({
loading: false
});
}
render() {
if (this.state.fontsAreLoaded == true) {
if (this.state.isLoggedIn === true) {
if (this.state.loading === true){
return <Spinner />
}else{
return (
<Somescreen/>
);
}
}
Upvotes: 0
Reputation: 1155
Works fine for me This is with NativeBase 2.3.6
<Content>
<Spinner />
<Spinner color="red" />
<Spinner color="green" />
<Spinner color="blue" />
</Content>
Works with <View>
as well
Upvotes: 2