AG-2653 Put React Hook example together, update docs
This commit is contained in:
32
src-examples/simpleReduxHooksExample/GridComponent.jsx
Normal file
32
src-examples/simpleReduxHooksExample/GridComponent.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React, { useContext } from "react";
|
||||
import {Context} from "./store";
|
||||
import {AgGridReact} from "ag-grid-react";
|
||||
|
||||
/*
|
||||
* This component serves to display the row data (provided by redux)
|
||||
*/
|
||||
export default function GridComponent() {
|
||||
const {store, dispatch} = useContext(Context);
|
||||
const {columnDefs, rowData} = store;
|
||||
|
||||
const onGridReady = (params) => {
|
||||
params.api.sizeColumnsToFit();
|
||||
};
|
||||
|
||||
// row data will be provided via redux on this.props.rowData
|
||||
return (
|
||||
<div style={{height: 400, width: 900, marginTop: 15}}
|
||||
className="ag-theme-balham">
|
||||
<AgGridReact
|
||||
// properties
|
||||
columnDefs={columnDefs}
|
||||
rowData={rowData}
|
||||
|
||||
reactNext={true}
|
||||
|
||||
// events
|
||||
onGridReady={onGridReady}>
|
||||
</AgGridReact>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user