Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FlatList] setNativeProps does not work with FlatList component #13501

Closed
liuzhibopp opened this issue Apr 14, 2017 · 6 comments
Closed

[FlatList] setNativeProps does not work with FlatList component #13501

liuzhibopp opened this issue Apr 14, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@liuzhibopp
Copy link

setNativeProps does not work with FlatList component

thanks in advance。

@huangxiwen
Copy link

i need the setNativeProps support too.

@henrikra
Copy link

Btw what are the advantages of using setNativeProps

@browniefed
Copy link
Contributor

It allows you to set the properties on the native component without triggering a set state to happen

@henrikra
Copy link

What are the benefits of that? Some use case for example?

@vonovak
Copy link
Contributor

vonovak commented Apr 21, 2017

@ide
Copy link
Contributor

ide commented Apr 21, 2017

There is a PR for this: #13529

@hramos hramos changed the title setNativeProps does not work with FlatList component [FlatList] setNativeProps does not work with FlatList component Apr 25, 2017
AdamPD pushed a commit to pharmadata/react-native that referenced this issue Jul 20, 2017
Summary:
Curently FlatList does not implement setting native props directly like the old ListView did. This pr introduce the `setNativeProps` function which delegates to MetroListView or VirtualizedList. Thos don't have `setNativeProps` handling either, so, I delegated further to the respective ListView and Scroll components, which do have handling for it, thus, allowing to set the native props through FlatList.

Create a project with a FlatList and change a native property using `setNativeProps`:

```javascript
  componentDidMount() {
        setInterval(() => {
            this.list.setNativeProps({ style: {backgroundColor:"white"} })
        }, 1000)
    }

  render() {
    return (
      <View style={styles.container}>
        <FlatList ref={component => this.list = component}
                  style={{backgroundColor:"black"}}
                  data={[{key: 'a'}, {key: 'b'}]}
                  renderItem={({item}) => <Text>{item.key}</Text>} />
      </View>
    )
  }
```

Fixes facebook#13501
Closes facebook#13529

Differential Revision: D5283593

Pulled By: sahrens

fbshipit-source-id: 8f96f88e286042d82452fef924689b5a8a783987
@facebook facebook locked as resolved and limited conversation to collaborators Jun 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants