headerRenderer component not receiving updates
HAVE YOU ALREADY SEARCHED FOR SIMILAR ISSUES? PLEASE HELP US OUT AND DOUBLE-CHECK FIRST!
ALSO, PLEASE DON'T BE THAT PERSON WHO DELETES THIS TEMPLATE. IT'S HERE FOR A REASON.
THANKS!
WHICH VERSION OF REACT ARE YOU USING?
Officially Supported:
[ ] v0.14.x
Community Supported:
[x] v15.0.x
WHICH BROWSER ARE YOU USING?
Officially Supported:
[ ] IE 9 / IE 10 / IE 11
[ ] Edge
[x] Chrome
Should work:
[ ] Firefox
[ ] Safari
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md
Current behavior
Using a custom headerRenderer component that requires props from state. I was unable to define the columns array in the recommended location getInitialState() since it was referencing state inside of it. So, I moved this to componentWillMount() and pushed it to state. This sets the initial value correctly in the headerRenderer component, however, this component will no longer receive new props as the state changes.
Expected/desired behavior headerRenderer component should re-render when prop updates. Is this the intended functionality or is there a better place to handle this?
Reproduction of the problem
componentWillMount() {
let columns = [
{...},
{
key: 'label',
name: 'Label',
sortable: true,
resizable: true,
draggable: true,
filterable: true,
headerRenderer: <ChildComponent
someProp={this.state.someValue}
/>
},
...]
this.setState({columns: columns})
}
Why the issue was closed while it's not resolved? Are there any workarounds to be used?
@dushes-ag I think it's due to inactivity for a long time.
https://github.com/adazzle/react-data-grid/pull/1148