Skip to content

Commit

Permalink
[core] Rely on immutable ref when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jan 28, 2024
1 parent d00e1de commit 7e76367
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/data/data-grid/editing/CustomEditComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function renderRating(params) {
function RatingEditInputCell(props) {
const { id, value, field, hasFocus } = props;
const apiRef = useGridApiContext();
const ref = React.useRef();
const ref = React.useRef(null);

const handleChange = (event, newValue) => {
apiRef.current.setEditCellValue({ id, field, value: newValue });
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/editing/CustomEditComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function renderRating(params: GridRenderCellParams<any, number>) {
function RatingEditInputCell(props: GridRenderCellParams<any, number>) {
const { id, value, field, hasFocus } = props;
const apiRef = useGridApiContext();
const ref = React.useRef<HTMLElement>();
const ref = React.useRef<HTMLElement>(null);

const handleChange = (event: React.SyntheticEvent, newValue: number | null) => {
apiRef.current.setEditCellValue({ id, field, value: newValue });
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/performance/GridVisualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useDemoData } from '@mui/x-data-grid-generator';

const TraceUpdates = React.forwardRef((props, ref) => {
const { Component, ...other } = props;
const rootRef = React.useRef();
const rootRef = React.useRef(null);
const handleRef = useForkRef(rootRef, ref);

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/performance/GridVisualization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useDemoData } from '@mui/x-data-grid-generator';

const TraceUpdates = React.forwardRef<any, any>((props, ref) => {
const { Component, ...other } = props;
const rootRef = React.useRef<HTMLElement>();
const rootRef = React.useRef<HTMLElement>(null);
const handleRef = useForkRef(rootRef, ref);

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ export const useGridColumnResize = (
const logger = useGridLogger(apiRef, 'useGridColumnResize');

const colDefRef = React.useRef<GridStateColDef>();
const columnHeaderElementRef = React.useRef<HTMLDivElement>();
const headerFilterElementRef = React.useRef<HTMLDivElement>();
const columnHeaderElementRef = React.useRef<HTMLDivElement | null>(null);
const headerFilterElementRef = React.useRef<HTMLDivElement | null>(null);
const groupHeaderElementsRef = React.useRef<Element[]>([]);
const cellElementsRef = React.useRef<Element[]>([]);
const leftPinnedCellsAfterRef = React.useRef<HTMLElement[]>([]);
const rightPinnedCellsBeforeRef = React.useRef<HTMLElement[]>([]);
const fillerLeftRef = React.useRef<HTMLElement>();
const fillerRightRef = React.useRef<HTMLElement>();
const fillerLeftRef = React.useRef<HTMLElement | null>(null);
const fillerRightRef = React.useRef<HTMLElement | null>(null);

// To improve accessibility, the separator has padding on both sides.
// Clicking inside the padding area should be treated as a click in the separator.
Expand Down

0 comments on commit 7e76367

Please sign in to comment.