Skip to content

[Bug] [v2] "contentContainerStyle" prop shows error when passing a "ViewStyle" value #1683

@alextbogdanov

Description

@alextbogdanov

From this comment: #848 (comment) it became apparent to me that we can now add more values to the "contentContainerStyle" prop in Flashlist v2.

I'm using "@shopify/flash-list": "^2.0.0-rc.2",

It seems that we can now add ViewStyle values to the "contentContainerStyle" prop. The problem is that if we add a value that's not in this list:

 "backgroundColor"
  | "paddingTop"
  | "paddingLeft"
  | "paddingRight"
  | "paddingBottom"
  | "padding"
  | "paddingVertical"
  | "paddingHorizontal"

typescript will give you the following error:

Object literal may only specify known properties, and 'flexGrow' does not exist in type 'ContentStyle'.ts(2353)
FlashListProps.d.ts(103, 5): The expected type comes from property 'contentContainerStyle' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FlashList> & Pick<Readonly<FlashListProps>, "scrollEnabled" | ... 184 more ... | "onCommitLayoutEffect"> & InexactPartial<...> & InexactPartial<...>'

We can get around this by doing:
import { ViewStyle } from "react-native"
and then
contentContainerStyle={{ flexGrow: 1 } as ViewStyle}

but we shouldn't have to do this as I can see that ContentStyle is updated to include ViewStyle, yet it doesn't detect it. In FlashListProps.ts we have:

export type ContentStyle = Pick<
  ViewStyle,
  | "backgroundColor"
  | "paddingTop"
  | "paddingLeft"
  | "paddingRight"
  | "paddingBottom"
  | "padding"
  | "paddingVertical"
  | "paddingHorizontal"
>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Edge case, has workaround, cosmetic, rarebugSomething isn't workingv2.0

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions