복붙노트

[REACTJS] 반응 네이티브의 파싱 된 개체 배열에서 이미지 렌더링

REACTJS

반응 네이티브의 파싱 된 개체 배열에서 이미지 렌더링

해결법


  1. 1.당신은 이렇게 할 수 있습니다

    당신은 이렇게 할 수 있습니다

      Details = [
            {
              type: "Party",
              image: require("../../../images/icons/photographer/Party.png")
            },
            {
              type: "Wedding",
              image: require("../../../images/icons/photographer/Wedding.png")
            },
            {
              type: "Architecture",
              image: require("../../../images/icons/photographer/Arhitecture.png")
            },
            {
              type: "Christening",
              image: require("../../../images/icons/photographer/Christening.png")
            }
      ];
    
      render() {
        let renderPhotoTypes = () => {
          let type = [];
    
          this.Details.map( ( item )=> {
            type.push(
              <View style={styles.imageSelectItem} key={item.type}>
                <TouchableWithoutFeedback>
                  <View>
                    <View style={styles.imageContainer}>
                      <Image style={styles.image} source={item.image}/>
                    </View>
                    <Text style={styles.text}>{item.type}</Text>
                  </View>
                </TouchableWithoutFeedback>
              </View>
            );
          } );
    
          return type;
        };
    
  2. from https://stackoverflow.com/questions/37841236/render-images-sources-from-parsed-array-of-objects-in-react-native by cc-by-sa and MIT license