ui icon indicating copy to clipboard operation
ui copied to clipboard

ListView strange behavior with data prop

Open ingoclaro opened this issue 7 years ago • 1 comments

Hi, I'm writing an Accordion component using a ListView and I noticed some strange behavior with the data prop.

In my component I need to make a copy of the data, like this:

render() {
    const data = Array.from(this.props.data) //hack to make ListView work
    return (
      <ListView
        data={data}
        renderRow={this._row}
        renderHeader={this._header}
        renderSectionHeader={this._sectionHeader}
        getSectionId={this._getSectionId}
      />
    )
  }

I can't pass this.props.data directly, if I do it, the state isn't changed when I click on the section headers.

Here is the code (although it doesn't work in the snack directly): https://snack.expo.io/@ingoclaro/accordion

This is an awesome library by the way, I ❤️ it!

ingoclaro avatar Feb 22 '18 19:02 ingoclaro

Another weird thing I noticed is that I'm getting the following warning, but I'm not passing any style:

ExceptionsManager.js:73 Warning: Failed prop type: Invalid prop `style` of type `number` supplied to `Styled(TouchableOpacity)`, expected `object`.
    in Styled(TouchableOpacity) (at Accordion.js:52)
    in ScrollViewStickyHeader (at ScrollView.js:700)
    in RCTScrollContentView (at ScrollView.js:717)
    in RCTScrollView (at ScrollView.js:811)
    in ScrollView (at ListView.js:338)
    in ListView (at ListView.js:306)
    in ListView (at connectStyle.js:248)
    in Styled(ListView) (at Accordion.js:76)
...

ingoclaro avatar Feb 22 '18 19:02 ingoclaro