Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#68539 [react-data-grid] Remove usage of de…
Browse files Browse the repository at this point in the history
…precated string refs in tests by @eps1lon
  • Loading branch information
eps1lon authored Feb 8, 2024
1 parent 54d2875 commit 52aee1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions types/react-data-grid/react-data-grid-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ var columns: Array<ReactDataGrid.Column<typeof counties>> = [
];

class Example extends React.Component<any, any> {
gridRef = React.createRef<ReactDataGrid<Array<{ id: number; title: string }>>>();
getInitialState() {
var fakeRows = createRows(2000);
return { rows: fakeRows };
Expand All @@ -255,7 +256,7 @@ class Example extends React.Component<any, any> {
onClick: (ev: React.SyntheticEvent<any>, args: { idx: number; rowIdx: number }) => {
var idx = args.idx;
var rowIdx = args.rowIdx;
(this.refs.grid as ReactDataGrid<{}>).openCellEditor(rowIdx, idx);
(this.gridRef.current!).openCellEditor(rowIdx, idx);
},
};

Expand Down Expand Up @@ -330,7 +331,7 @@ class Example extends React.Component<any, any> {
let selectedRows = ["id1", "id2"];
return (
<ReactDataGrid
ref="grid"
ref={this.gridRef}
enableCellSelect={true}
enableDragAndDrop={true}
columns={this.getColumns()}
Expand Down
5 changes: 3 additions & 2 deletions types/react-data-grid/v1/react-data-grid-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var columns: ReactDataGrid.Column[] = [
];

class Example extends React.Component<any, any> {
gridRef = React.createRef<ReactDataGrid>();
getInitialState() {
var fakeRows = createRows(2000);
return { rows: fakeRows };
Expand All @@ -201,7 +202,7 @@ class Example extends React.Component<any, any> {
onClick: (ev: React.SyntheticEvent<any>, args: { idx: number; rowIdx: number }) => {
var idx = args.idx;
var rowIdx = args.rowIdx;
this.refs.grid as ReactDataGrid;
this.gridRef!;
},
};

Expand Down Expand Up @@ -258,7 +259,7 @@ class Example extends React.Component<any, any> {
let selectedRows = ["id1", "id2"];
return (
<ReactDataGrid
ref="grid"
ref={this.gridRef}
enableCellSelect={true}
columns={this.getColumns()}
rowGetter={this.getRowAt}
Expand Down
5 changes: 3 additions & 2 deletions types/react-data-grid/v2/react-data-grid-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ var columns: ReactDataGrid.Column[] = [
];

class Example extends React.Component<any, any> {
gridRef = React.createRef<ReactDataGrid>();
getInitialState() {
var fakeRows = createRows(2000);
return { rows: fakeRows };
Expand All @@ -255,7 +256,7 @@ class Example extends React.Component<any, any> {
onClick: (ev: React.SyntheticEvent<any>, args: { idx: number; rowIdx: number }) => {
var idx = args.idx;
var rowIdx = args.rowIdx;
(this.refs.grid as ReactDataGrid).openCellEditor(rowIdx, idx);
this.gridRef.current.openCellEditor(rowIdx, idx);
},
};

Expand Down Expand Up @@ -333,7 +334,7 @@ class Example extends React.Component<any, any> {
let selectedRows = ["id1", "id2"];
return (
<ReactDataGrid
ref="grid"
ref={this.gridRef}
enableCellSelect={true}
enableDragAndDrop={true}
columns={this.getColumns()}
Expand Down

0 comments on commit 52aee1d

Please sign in to comment.