|
| 1 | +--- |
| 2 | +title: FlashListWithHeaders |
| 3 | +hide_table_of_contents: false |
| 4 | +slug: /components/Flash-list-with-headers |
| 5 | +description: Shopify's FlashList paired with React Native Header. |
| 6 | +--- |
| 7 | + |
| 8 | +Component that extends Shopify's [FlashList](https://shopify.github.io/flash-list/docs/) to add support for |
| 9 | +headers exported from this library. |
| 10 | + |
| 11 | +The implementation of this component relies on the [HeaderComponent](/docs/components/flash-list-with-headers#headercomponent) |
| 12 | +and [LargeHeaderComponent](/docs/components/flash-list-with-headers#largeheadercomponent) props. |
| 13 | +The [HeaderComponent](/docs/components/flash-list-with-headers#headercomponent) is rendered above |
| 14 | +the FlashList and the [LargeHeaderComponent](/docs/components/flash-list-with-headers#largeheadercomponent) |
| 15 | +is rendered as the `ListHeaderComponent` of the FlashList. Using these two props will allow for |
| 16 | +animations/built-in features in this library to work properly. |
| 17 | + |
| 18 | +## Note |
| 19 | + |
| 20 | +This component is only available in react-native-header version >= `0.9.x`. Please review the [Compatibility matrix](/docs/getting-started#compatibility) and ensure |
| 21 | +you have the correct dependencies installed in your project before using this component. |
| 22 | + |
| 23 | +## Props |
| 24 | + |
| 25 | +This component uses the FlashList under the hood, which inherits [all of the props |
| 26 | +from the FlashList component](https://shopify.github.io/flash-list/docs/usage). |
| 27 | + |
| 28 | +### HeaderComponent |
| 29 | + |
| 30 | +The component to render above the FlashList. This accepts a function that returns a React Element |
| 31 | +to display as the header. The function will be called with the following arguments: |
| 32 | + |
| 33 | +- `showNavBar`: An animated value that will be 0 when the header's subcomponents should be hidden |
| 34 | + and 1 when they should be shown. This is useful for animating the header's subcomponents. The |
| 35 | + [Header](/docs/components/header) component uses this value to animate its left, center, and |
| 36 | + right children. |
| 37 | + |
| 38 | +### LargeHeaderComponent |
| 39 | + |
| 40 | +An optional component to render as the large header for this component. This accepts a function |
| 41 | +that returns a React Element to display as the large header. The function will be called with the |
| 42 | +following arguments: |
| 43 | + |
| 44 | +- `scrollY`: An animated value that keeps track of the current scroll position of the FlashList. |
| 45 | + This prop is useful for creating custom animations on the large header. In our [example](/docs/example), |
| 46 | + we use the [ScalingView](/docs/components/scaling-view) component to scale the large header |
| 47 | + when the user pulls down on the FlashList (to mimic native iOS behaviour). |
| 48 | +- `showNavBar`: An animated value that keeps track of whether or not the small header is hidden. |
| 49 | + This prop is useful if you want to create your own custom animations based on whether or not the |
| 50 | + small header is hidden. |
| 51 | + |
| 52 | +### ignoreLeftSafeArea |
| 53 | + |
| 54 | +An optional boolean that determines whether or not to ignore the left safe area. Defaults to |
| 55 | +`false`. The safe area adjustments are used to make sure that the scroll container does not |
| 56 | +overlap with the notch/headers on different phones - leave this prop as false if you want to |
| 57 | +respect those safe areas. |
| 58 | + |
| 59 | +### ignoreRightSafeArea |
| 60 | + |
| 61 | +An optional boolean that determines whether or not to ignore the right safe area. Defaults to |
| 62 | +`false`. The safe area adjustments are used to make sure that the scroll container does not |
| 63 | +overlap with the notch/headers on different phones - leave this prop as `false` if you want to |
| 64 | +respect those safe areas. |
| 65 | + |
| 66 | +### disableAutoFixScroll |
| 67 | + |
| 68 | +An optional to disable the auto fix scroll mechanism. This is useful if you want to disable the |
| 69 | +auto scroll when the large header is partially visible. Defaults to `false`. |
| 70 | + |
| 71 | +### containerStyle |
| 72 | + |
| 73 | +An optional style object that will be applied to the parent container of the scroll container. |
| 74 | + |
| 75 | +### largeHeaderContainerStyle |
| 76 | + |
| 77 | +An optional style object that will be applied to the large header container. |
| 78 | + |
| 79 | +### largeHeaderShown |
| 80 | + |
| 81 | +An optional animated [Shared Value](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/shared-values/) |
| 82 | +that will be mutated by the library when the large header is shown or hidden. This is useful if you |
| 83 | +would like to track when the large header is shown or hidden. |
| 84 | + |
| 85 | +### onLargeHeaderLayout |
| 86 | + |
| 87 | +An optional callback that will be called when the large header is laid out. This is useful if you |
| 88 | +want to access the layout of the large header to calculate the height of the large header. |
0 commit comments