小编Muh*_*lha的帖子

反应原始flatlist最后一项可见性问题

我正在获取产品列表,然后使用平面列表显示,我的列表包含5个项目,因为您可以看到由于不同的描述文本,平面列表行高度是可变的.所以问题是我的最后一项卡片不完全可见,这可能是某种平面列表问题或布局问题.任何帮助将受到高度赞赏

 renderProducts() {
        if (this.props.loading === true) {
            return (
                <View style={Styles.spinnerStyle}>
                    <ActivityIndicator size='large' />
                </View>
            );
        }

        return (
                <FlatList
                    data={this.props.myProducts}
                    keyExtractor={(item) => item.id}
                    renderItem={({ item }) => (
                        <Card 
                            title={item.title} 
                            image={{ 
                                uri: item.image !== null ? item.image.src :'../resImage.jpg' 
                            }}
                        >
                            <Text style={{ marginBottom: 10 }}>
                                {item.body_html}
                            </Text>
                            <Button
                                icon={{ name: 'code' }}
                                backgroundColor='#03A9F4'
                                fontFamily='Lato'
                                buttonStyle={{ borderRadius: 0, marginLeft: 0, marginRight: 0, marginBottom: 0 }}
                                title='VIEW NOW' 
                            />
                      </Card>
                      )}
                />
        );
    }

    render() {
        return (
            <View>
                <View …
Run Code Online (Sandbox Code Playgroud)

react-native

16
推荐指数
8
解决办法
1万
查看次数

Graphql 查询错误!变量已声明但从未使用

我正在尝试根据搜索关键字获取 Shopify 产品。

我通过在查询中传递硬编码值来测试此查询,它工作正常,但我需要传递变量值,因此在这种情况下它会给出错误

Grapghql 查询错误 searchKeyword 已声明但未使用。

这是我根据title,tag和搜索产品的查询product_type

不成功案例:

export const searchProductsQuery = gql` query($searchKeyword: String!){
    shop {
        products(first: 10, query:"title:'$searchKeyword' OR tag:'$searchKeyword' OR product_type:'$searchKeyword'") {
            edges {
                cursor
                node {
                    id
                    title
                    handle
                    description
                    productType
                    images(first: 5) {
                        edges {
                            node {
                                id
                                src
                            }
                        }
                    }
                    variants(first: 5) {
                        edges {
                            node {
                                id
                                title
                                price
                            }
                        }
                    }
                }
            }
        }
    }
}`;
Run Code Online (Sandbox Code Playgroud)

成功案例:

export const searchProductsQuery = gql` query{ …
Run Code Online (Sandbox Code Playgroud)

javascript shopify react-native graphql-js react-apollo

6
推荐指数
1
解决办法
6981
查看次数