Skip to content

Instantly share code, notes, and snippets.

@jsoendermann
Last active December 9, 2019 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsoendermann/fd1155366069250bcb5a12531647757f to your computer and use it in GitHub Desktop.
Save jsoendermann/fd1155366069250bcb5a12531647757f to your computer and use it in GitHub Desktop.
sectionListGetItemLayout
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}
/>
)
}
}
@cguillemette
Copy link

There's a missing } for the wrapped object passed on to sectionListGetItemLayout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment