Skip to content

Commit

Permalink
add setNativeProps to SectionList
Browse files Browse the repository at this point in the history
Summary:
```js
componentDidMount() {
  this._list.setNativeProps({scrollEnabled: false})
}

render() {
  const sections = [
    {key: 'foo', data: [{name: 'Jone Doe', key: 'a'}, {name: 'Susan Briz', key: 'b'}],
    {key: 'bar', data: [{name: 'David Mark', key: 'c'}, {name: 'Daniel Campbell', key: 'd'}]
  ]

  return (
    <SectionList
      ref={c => (this._list = c)}
      sections={sections}
      renderItem={({item}) => <Text>{item.name}<Text>}
    />
  )
}
```
Closes #15328

Differential Revision: D5546636

Pulled By: javache

fbshipit-source-id: 25aec067879be1571db5c3a09b5f0952826220ac
  • Loading branch information
octopitus authored and facebook-github-bot committed Aug 3, 2017
1 parent 36c6943 commit ccb0899
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
}
}

setNativeProps(props: Object) {
const listRef = this._wrapperListRef && this._wrapperListRef.getListRef();
if (listRef) {
listRef.setNativeProps(props);
}
}

render() {
const List = this.props.legacyImplementation
? MetroListView
Expand Down

0 comments on commit ccb0899

Please sign in to comment.