Как я могу добавить изображения в реагирующую родную схему расположения? В репозитории Github нет упоминаний о реквизитах - PullRequest
0 голосов
/ 14 мая 2019

Я использую пакет Reaction-native-layout-grid для отображения макета сетки.Я хочу добавить изображения в сетке вместо текста / строки.Как я могу это сделать?

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
} from 'react-native';
import GridLayout from 'react-native-layout-grid';

export default class App extends Component<{}> {

  renderGridItem = (item) => (
    <View style={styles.item}>
      <View style={styles.flex} />
      <Text style={styles.name}>
        {item.name}
      </Text>
    </View>
  );

  render() {
    const items = [];
    for (let x = 1; x <= 30; x++) {
      items.push({
        name: `Grid ${x}`
      });
    }
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Grid Layout
        </Text>
        <View style={styles.flex}>
          <GridLayout
            items={items}
            itemsPerRow={3}
            renderItem={this.renderGridItem}
          />
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
 ///styles///
});

Мне нужно добавлять изображения вместо текстовых строк, передаваемых в реквизит. Есть ли способ сделать это?Заранее спасибо.

1 Ответ

0 голосов
/ 14 мая 2019

В renderGridItem добавьте изображения Например: ---

 renderGridItem = (item) => (
    <View style={styles.item}>
      <View style={styles.flex} />
<Image
          style={{width: 50, height: 50}}
          source={{uri: 'https://facebook.github.io/react-native/docs/assets/favicon.png'}}
        />
      <Text style={styles.name}>
        {item.name}
      </Text>
    </View>
  );

работает например: https://snack.expo.io/@msbot01/petrified-tortillas

...