React native React Native FlatList未滚动

React native React Native FlatList未滚动,react-native,react-native-flatlist,React Native,React Native Flatlist,我正在开发一个React本地应用程序,用于学习。现在我在应用程序中使用FlatList。但是我有个问题。我的平面列表无法滚动查看所有项目。当我试图将其滚动到屏幕大小之外时,它会反弹。我使用了我在网上找到的解决方案,将flex添加到根目录上的1,但它不起作用 这是我的密码: class Events extends React.Component { static navigationOptions = { title: "Events" }; constructor(pro

我正在开发一个React本地应用程序,用于学习。现在我在应用程序中使用FlatList。但是我有个问题。我的平面列表无法滚动查看所有项目。当我试图将其滚动到屏幕大小之外时,它会反弹。我使用了我在网上找到的解决方案,将flex添加到根目录上的1,但它不起作用

这是我的密码:

class Events extends React.Component {
  static navigationOptions = {
    title: "Events"
  };

  constructor(props) {
    super(props);
    this.state = {
      data: [
        {
          id: 1,
          name: "Name 1"
        },
        {
          id: 2,
          name: "Name 2"
        },
        {
          id: 3,
          name: "Name 3"
        },
        {
          id: 4,
          name: "Name 4"
        },
        {
          id: 5,
          name: "Name 5"
        },
        {
          id: 6,
          name: "Name 6"
        },
        {
          id: 7,
          name: "Name 7"
        },
        {
          id: 8,
          name: "Name 8"
        },
        {
          id: 9,
          name: "Name 9"
        },
        {
          id: 10,
          name: "Name 10"
        },
        {
          id: 11,
          name: "Name 11"
        },
        {
          id: 12,
          name: "Name 12"
        },
        {
          id: 13,
          name: "Name 13"
        },
        {
          id: 14,
          name: "Name 14"
        },
        {
          id: 15,
          name: "Name 15"
        },
        {
          id: 16,
          name: "Name 16"
        },
        {
          id: 17,
          name: "Name 17"
        },
        {
          id: 18,
          name: "Name 18"
        },
        {
          id: 19,
          name: "Name 19"
        },
        {
          id: 20,
          name: "Name 20"
        },
        {
          id: 21,
          name: "Name 21"
        },
        {
          id: 22,
          name: "Name 22"
        },
        {
          id: 23,
          name: "Name 23"
        },
        {
          id: 24,
          name: "Name 24"
        }
      ]
    };
  }

  _handleLoadMore() {}

  renderItem(item) {
    return (
      <Card>
        <CardItem>
          <Left>
            <Thumbnail source={{ uri: "https://www.vkguy.co.uk/images/slideshow/05.jpg" }} />
            <Body>
              <Text>NativeBase</Text>
              <Text note>GeekyAnts</Text>
            </Body>
          </Left>
        </CardItem>
        <CardItem cardBody>
          <Image
            source={{ uri: "https://www.vkguy.co.uk/images/slideshow/05.jpg" }}
            style={{ height: 200, width: null, flex: 1 }}
          />
        </CardItem>
        <CardItem>
          <Left>
            <Button transparent>
              <Icon active name="thumbs-up" />
              <Text>12 Likes</Text>
            </Button>
          </Left>
          <Body>
            <Button transparent>
              <Icon active name="chatbubbles" />
              <Text>4 Comments</Text>
            </Button>
          </Body>
          <Right>
            <Text>11h ago</Text>
          </Right>
        </CardItem>
      </Card>
    );
  }

  render() {
    return (
        <FlatList
        contentContainerStyle={{
          flex: 1,
          flexDirection: "column",
          height: "100%",
          width: "100%"
        }}
        data={this.state.data}
        keyExtractor={item => item.id.toString()}
        renderItem={({ item }) => this.renderItem(item)}
        onEndReached={this._handleLoadMore}
      />
    );
  }
}

export default Events;
类事件扩展React.Component{
静态导航选项={
标题:“活动”
};
建造师(道具){
超级(道具);
此.state={
数据:[
{
id:1,
姓名:“姓名1”
},
{
id:2,
姓名:“姓名2”
},
{
id:3,
姓名:“姓名3”
},
{
id:4,
姓名:“姓名4”
},
{
id:5,
姓名:“姓名5”
},
{
id:6,
姓名:“姓名6”
},
{
id:7,
姓名:“姓名7”
},
{
id:8,
姓名:“姓名8”
},
{
id:9,
姓名:“姓名9”
},
{
id:10,
姓名:“姓名10”
},
{
id:11,
姓名:“姓名11”
},
{
id:12,
姓名:“姓名12”
},
{
id:13,
姓名:“姓名13”
},
{
身份证号码:14,
姓名:“姓名14”
},
{
身份证号码:15,
姓名:“姓名15”
},
{
身份证号码:16,
姓名:“姓名16”
},
{
身份证号码:17,
姓名:“姓名17”
},
{
身份证号码:18,
姓名:“姓名18”
},
{
身份证号码:19,
姓名:“姓名19”
},
{
身份证号码:20,
姓名:“姓名20”
},
{
id:21,
姓名:“姓名21”
},
{
身份证号码:22,
姓名:“姓名22”
},
{
id:23,
姓名:“姓名23”
},
{
id:24,
姓名:“姓名24”
}
]
};
}
_handleLoadMore(){}
renderItem(项目){
返回(
本土基地
极客
12喜欢
4评论
11小时前
);
}
render(){
返回(
item.id.toString()}
renderItem={({item})=>this.renderItem(item}
onEndReached={this.\u handleLoadMore}
/>
);
}
}
导出默认事件;
但它不是滚动来查看屏幕上的项目。我怎样才能修好它

这是截图。我不能再往下滚动了


FlatList
视图中更改一些样式,并将
视图添加为主容器

render() {
    return (
        <View style={{ flex: 1, width: '100%' }}>
            <FlatList 
                data={this.state.data}
                keyExtractor={item => item.id.toString()}
                renderItem={({ item }) => this.renderItem(item)}
                onEndReached={this._handleLoadMore}
            />
        </View>
    );
  }
render(){
返回(
item.id.toString()}
renderItem={({item})=>this.renderItem(item}
onEndReached={this.\u handleLoadMore}
/>
);
}

平面列表
视图中更改一些样式,并添加
视图
作为主容器

render() {
    return (
        <View style={{ flex: 1, width: '100%' }}>
            <FlatList 
                data={this.state.data}
                keyExtractor={item => item.id.toString()}
                renderItem={({ item }) => this.renderItem(item)}
                onEndReached={this._handleLoadMore}
            />
        </View>
    );
  }
render(){
返回(
item.id.toString()}
renderItem={({item})=>this.renderItem(item}
onEndReached={this.\u handleLoadMore}
/>
);
}
尝试使用

<FlatList
    contentContainerStyle={{ flexGrow: 1, paddingBottom: 5 }}
    data={this.state.data}
    keyExtractor={item => item.id.toString()}
    renderItem={({ item }) => this.renderItem(item)}
    onEndReached={this._handleLoadMore}
    onEndReachedThreshold={0.5}
  />
item.id.toString()}
renderItem={({item})=>this.renderItem(item}
onEndReached={this.\u handleLoadMore}
onEndReachedThreshold={0.5}
/>
尝试使用

<FlatList
    contentContainerStyle={{ flexGrow: 1, paddingBottom: 5 }}
    data={this.state.data}
    keyExtractor={item => item.id.toString()}
    renderItem={({ item }) => this.renderItem(item)}
    onEndReached={this._handleLoadMore}
    onEndReachedThreshold={0.5}
  />
item.id.toString()}
renderItem={({item})=>this.renderItem(item}
onEndReached={this.\u handleLoadMore}
onEndReachedThreshold={0.5}
/>

Hi,这并不能解决问题。我也附上了截图。让我们从
Flatlist
中删除
style
道具。请参阅我编辑的答案。让我来更新它是否有效。嗨,这解决了问题。你又帮了我。干杯。嗨,这不能解决问题。我也附上了截图。让我们从
Flatlist
中删除
style
道具。请参阅我编辑的答案。让我来更新它是否有效。嗨,这解决了问题。你又帮了我。干杯。