Member Avatar for ShilohAmi

Hello, I am newbie and start learning Android mobile programming using react native.. I encounter a problem using setState state, it's keep show an error : "Can't find variable : setState"

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';

export default class WeatherProject extends Component {
  constructor(props) {
    super (props)
    this.state={appendText:'crazy!'};
  }
  render () {
    return (
      <View> <Text onPress={() => setState({text: ' Native'})}>{this.
          props.setState +" "+ this.state.appendText}</Text> </View>
);
}
}

AppRegistry.registerComponent('WeatherProject', () => WeatherProject);

Could someone pointed where is the problem in the code?

use this.setState() instead of setState().
Never use setState() directly without this.

Ex. this.setState({ text :'Native' })

use this.setState() instead of setState().

commented: This just repeats an earlier answer -3

What language do you use?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.