Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Please tell me how to write function in jacascript

$
0
0

I was looking at this example because I wanted to show the current location on the map, just struggling to write the example in my own code

https://github.com/react-native-community/react-native-maps this is exsample

getInitialState() {
  return {
    region: {
      latitude: 37.78825,
      longitude: -122.4324,
      latitudeDelta: 0.0922,
      longitudeDelta: 0.0421,
    },
  };
}

onRegionChange(region) {
  this.setState({ region });
}

render() {
  return (
    <MapView
      region={this.state.region}
      onRegionChange={this.onRegionChange}
    />
  );
}

my code is not funcition.

const Map = () => {

  render(){
    const  getInitialState =() => {
      return {
        region: {
          latitude: 37.78825,
          longitude: -122.4324,
          latitudeDelta: 0.0922,
          longitudeDelta: 0.0421,
        },
      }
    };

   const  onRegionChange = (region) => {
        this.setState({ region });
      }


    return (
      <MapView
        style={styles.map}
        region={this.state.region}
        onRegionChange={this.state.onRegionChange}
      />
    )
  }
}

export default Map;

I'm having trouble writing the example code myself. How to make funciton work well


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>