Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { StyleSheet, View, Image, Text, TextInput, TouchableOpacity, StatusBar, Button, FlatList } from 'react-native';
- export default class Login extends Component {
- constructor() {
- super()
- this.state = {
- PriceList: []
- }
- }
- renderItem = (item) => {
- return (
- <View>
- <Text>
- {item.price1}
- </Text>
- <Text>
- {item.DenumireOferta}
- </Text>
- </View>
- )
- }
- componentDidMount() {
- fetch(
- "http://192.168.0.103:8080/twist/connection/getdata.php",
- {
- header: {
- Accept: "application/json",
- "Content-type": "application/json",
- }
- }
- )
- .then((response) => response.json())
- .then((responseJson) => {
- console.log('ceva1',responseJson);
- this.setState({
- PriceList: responseJson.user
- })
- })
- .catch ((error) =>{
- console.log(error)
- })
- }
- render() {
- return (
- <View style={styles.container}>
- <FlatList
- data={this.state.PriceList}
- renderItem={this.renderItem}
- />
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- padding: 20,
- flex: 1,
- },
- cardstyle: {
- margin: 5,
- backgroundColor: 'grey',
- borderRadius: 10
- },
- listing: {
- flex: 1,
- flexDirection: 'column-reverse',
- padding: 15,
- textShadowColor: "black",
- marginLeft: 10
- }
- });
Add Comment
Please, Sign In to add comment