react-native-camera-roll-picker icon indicating copy to clipboard operation
react-native-camera-roll-picker copied to clipboard

containerWidth doesn't update dynamically.

Open z4ph0rd opened this issue 7 years ago • 2 comments

Component is not rerendering when containerWidth updated .

z4ph0rd avatar Jul 31 '17 06:07 z4ph0rd

I have the same issue, I was trying to send data that will change width state, but it doesn't update containerWidth={this.state.width}

_handleLayout = event => {
    this.setState({
      width: event.nativeEvent.layout.width
    });
  }

on the render... <View onLayout={this._handleLayout}>

BonnieMilian avatar Dec 06 '17 17:12 BonnieMilian

Uhh I found a solution on the index.js file: on render function, add onLayout:

return (
      <View
        onLayout={this._handleLayout}

add function_ handleLayout:

_handleLayout = event => {
    this.fetch();
    this.setState({initialLoading: true, dataSource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})});
  }

BonnieMilian avatar Dec 06 '17 18:12 BonnieMilian