bencripps / react-redux-grid

A React Grid/Tree Component written in the Redux Pattern
http://react-redux-grid.herokuapp.com/
MIT License
446 stars 63 forks source link

Old props while dispatching actions from cell #208

Open mglombiowski opened 6 years ago

mglombiowski commented 6 years ago

I see in the code that the columns are set only once for component mount. This causes issues with passing dispatch methods.

Lets say that in each row there is a button, that will dispatch an action. Method itself is defined in higher order component and some additional props are passed there. Because the columns are set ony once, the attached method is keeping the old 'bind', so for example the new props will not apply.

Pseudocode:

submitAction() {
  console.log(this.props) // this.props will point to props that were passed on the first render
}
render() {
  <Grid columns=[
    renderer: <span onCllick={this.submitAction.bind(this)}/>
  ]/>
}

I cant imagine having every interactive cell as a container that will pick newest props on its own, nor passing a lot of additional data, not required for render in 'row' property.