react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

headerRenderer component not receiving updates

Open nolanseaton opened this issue 9 years ago • 3 comments

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})
}

nolanseaton avatar May 23 '17 17:05 nolanseaton

Why the issue was closed while it's not resolved? Are there any workarounds to be used?

dushes-ag avatar Mar 06 '18 15:03 dushes-ag

@dushes-ag I think it's due to inactivity for a long time.

qili26 avatar Mar 06 '18 18:03 qili26

https://github.com/adazzle/react-data-grid/pull/1148

klacointe avatar Mar 26 '18 12:03 klacointe