【问题标题】:Adding delete button in flat list react native在平面列表中添加删除按钮反应原生
【发布时间】:2020-06-05 13:51:01
【问题描述】:

我正在尝试在平面列表中每个列表的末尾添加一个删除按钮。预期的行为是从数组中删除列表。所以我添加了 press 方法并调用 alert 来检查它是否工作正常。

现在,每当我将一项添加到我的平面列表中时。此警报弹出窗口即将到来。但是点击我的删除按钮弹出没有显示。不知道我添加的位置是否正确。

我是本机反应的新手。请帮助。

                <FlatList
                    data={data.ingredientArray}
                    width='100%'
                    extraData={data.ingredientArray}
                    keyExtractor={(index) => index.toString()}
                    ItemSeparatorComponent={this.FlatListItemSeparator}
                    renderItem={({ item }) =>
                        <View style={styles.TextViewStyle}>
                            <View style={styles.row}>
                                <View style={styles.bullet}>
                                    <Text style={{ fontWeight: 'bold', fontSize: 16 }}>{'\u2022' + " "}</Text>
                                </View>
                                <View style={styles.bulletText}>
                                    <Text style={{ fontWeight: 'normal', fontSize: 16, color: '#009387' }}>{item.title}</Text>
                                </View>
                                <View>
                                </View>
                                <Feather
                                    name="x-circle"
                                    color="#009387"
                                    size={30}
                                    onPress={showAlert}
                                />
                            </View>
                        </View>
                    } />

我的提醒:

const showAlert = () => {
alert('alert me');
}

对此有什么帮助吗?

【问题讨论】:

    标签: javascript reactjs react-native visual-studio-code


    【解决方案1】:

    您可以将onPress={showAlert} 更改为onPress={() =&gt; showAlert()} ??

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多