thegamenicorus / react-native-timeline-listview

Timeline component for React Native App
https://www.npmjs.com/package/react-native-timeline-listview
MIT License
1.16k stars 184 forks source link

Bind props render methods to this #8

Closed mielvds closed 7 years ago

mielvds commented 7 years ago

The renderTime, renderCircle and renderDetail that you can override do not bound this to the component instance itself. This makes a reuse of the original render functions impossiblen which is useful if you want to add conditional rendering. Also, you cannot reach this.state, which, for instance, causes issues with positioning the circle.

I propose to use

this.renderTime = (this.props.renderTime?this.props.renderTime:this._renderTime).bind(this)
this.renderDetail = (this.props.renderDetail?this.props.renderDetail:this._renderDetail).bind(this)
this.renderCircle = (this.props.renderCircle?this.props.renderCircle:this._renderCircle).bind(this)
thegamenicorus commented 7 years ago

Hello @mielvds

Thank you for your help. I'll release new version soon. 😃

thegamenicorus commented 7 years ago

update in v.0.2.2

Thanks again 👍