Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Use explicit definition instead of React.FC #1325

Closed
1 task done
m4theushw opened this issue Mar 31, 2021 · 0 comments · Fixed by #1436
Closed
1 task done

[DataGrid] Use explicit definition instead of React.FC #1325

m4theushw opened this issue Mar 31, 2021 · 0 comments · Fixed by #1436
Labels
component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes typescript

Comments

@m4theushw
Copy link
Member

m4theushw commented Mar 31, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

We're typing many components with React.FC. One of the problems with this approach is that it provides an implicit definition of the children prop, even for those components that don't use it. We should favor an explicit definition instead.

diff --git a/packages/grid/_modules_/grid/components/GridRowCount.tsx b/packages/grid/_modules_/grid/components/GridRowCount.tsx
index 4d888ce..45ca4a3 100644
--- a/packages/grid/_modules_/grid/components/GridRowCount.tsx
+++ b/packages/grid/_modules_/grid/components/GridRowCount.tsx
@@ -1,7 +1,11 @@
 import * as React from 'react';
 import { GridApiContext } from './GridApiContext';

-export const GridRowCount: React.FC<{ rowCount: number }> = ({ rowCount }) => {
+export interface GridRowCountProps {
+  rowCount: number
+}
+
+export const GridRowCount = (props: GridRowCountProps) => {
+  const { rowCount } = props;
   const apiRef = React.useContext(GridApiContext);

   if (rowCount === 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants