Guest User

Untitled

a guest
Jun 15th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { StyleSheet, View, Image, Text, TextInput, TouchableOpacity, StatusBar, Button, FlatList } from 'react-native';
  3.  
  4.  
  5.  
  6.  
  7.  
  8. export default class Login extends Component {
  9. constructor() {
  10. super()
  11. this.state = {
  12. PriceList: []
  13. }
  14. }
  15. renderItem = (item) => {
  16. return (
  17. <View>
  18. <Text>
  19. {item.price1}
  20. </Text>
  21. <Text>
  22. {item.DenumireOferta}
  23. </Text>
  24. </View>
  25. )
  26.  
  27. }
  28. componentDidMount() {
  29.  
  30.  
  31. fetch(
  32. "http://192.168.0.103:8080/twist/connection/getdata.php",
  33. {
  34.  
  35. header: {
  36. Accept: "application/json",
  37. "Content-type": "application/json",
  38. }
  39. }
  40. )
  41. .then((response) => response.json())
  42. .then((responseJson) => {
  43. console.log('ceva1',responseJson);
  44. this.setState({
  45.  
  46. PriceList: responseJson.user
  47.  
  48. })
  49.  
  50.  
  51. })
  52. .catch ((error) =>{
  53. console.log(error)
  54. })
  55. }
  56. render() {
  57. return (
  58.  
  59.  
  60. <View style={styles.container}>
  61. <FlatList
  62. data={this.state.PriceList}
  63. renderItem={this.renderItem}
  64. />
  65.  
  66.  
  67. </View>
  68.  
  69.  
  70. );
  71. }
  72. }
  73. const styles = StyleSheet.create({
  74. container: {
  75. padding: 20,
  76. flex: 1,
  77. },
  78. cardstyle: {
  79.  
  80. margin: 5,
  81. backgroundColor: 'grey',
  82. borderRadius: 10
  83. },
  84. listing: {
  85. flex: 1,
  86. flexDirection: 'column-reverse',
  87. padding: 15,
  88. textShadowColor: "black",
  89. marginLeft: 10
  90.  
  91. }
  92.  
  93. });
Add Comment
Please, Sign In to add comment