Last active
December 9, 2019 21:16
-
-
Save jsoendermann/fd1155366069250bcb5a12531647757f to your computer and use it in GitHub Desktop.
sectionListGetItemLayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sectionListGetItemLayout from 'react-native-section-list-get-item-layout' | |
class MyComponent extends React.Component { | |
constructor(props) { | |
super(props) | |
this.getItemLayout = sectionListGetItemLayout({ | |
// The height of the row with rowData at the given sectionIndex and rowIndex | |
getItemHeight: (rowData, sectionIndex, rowIndex) => sectionIndex === 0 ? 100 : 50, | |
// These three properties are optional | |
getSeparatorHeight: () => 1 / PixelRatio.get(), // The height of your separators | |
getSectionHeaderHeight: () => 20, // The height of your section headers | |
getSectionFooterHeight: () => 10, // The height of your section footers | |
}) | |
} | |
render() { | |
return ( | |
<SectionList | |
{...otherStuff} | |
getItemLayout={this.getItemLayout} | |
/> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a missing } for the wrapped object passed on to sectionListGetItemLayout.