AG-3316 agGridReact needs to be updated to use the updated react lifecycle hooks

This commit is contained in:
Sean Landsman
2019-09-25 12:22:09 +01:00
parent b9b2b03a6b
commit 0584234be7
5 changed files with 24 additions and 6 deletions

View File

@@ -45,8 +45,6 @@ class GridComponent extends Component {
columnDefs={this.state.columnDefs}
rowData={this.props.rowData}
reactNext={true}
// events
onGridReady={this.onGridReady}>
</AgGridReact>
@@ -62,4 +60,4 @@ export default connect(
rowData: state.rowData
}
}
)(GridComponent);
)(GridComponent);

View File

@@ -41,5 +41,5 @@ export default connect(
},
null,
null,
{forwardRef: true} // must be supplied for react/redux when using GridOptions.reactNext
)(PriceRenderer);
{forwardRef: true} // must be supplied for react/redux when using AgGridReact
)(PriceRenderer);

View File

@@ -22,7 +22,7 @@ export default function GridComponent() {
columnDefs={columnDefs}
rowData={rowData}
reactNext
defaultColDef={{filter: true}}
// events
onGridReady={onGridReady}>

View File

@@ -0,0 +1,18 @@
import React, {forwardRef, useImperativeHandle, useRef} from "react";
export default forwardRef((props, ref) => {
const inputRef = useRef();
useImperativeHandle(ref, () => {
return {
isFilterActive() {
return inputRef.current.value !== '';
},
doesFilterPass: (params) => {
return params.data.price.toString() === inputRef.current.value;
}
};
});
return <input type="text" ref={inputRef} onChange={() => props.filterChangedCallback()}/>;
})

View File

@@ -1,6 +1,7 @@
import React from "react";
import PriceRenderer from "./PriceRenderer";
import PriceEditor from "./PriceEditor";
import PriceFilter from "./PriceFilter";
export const initialState = {
rowData: [],
@@ -14,6 +15,7 @@ export const initialState = {
cellClass: 'align-right',
editable: true,
cellEditorFramework: PriceEditor,
filterFramework: PriceFilter,
cellRendererFramework: PriceRenderer
}
]