-
Notifications
You must be signed in to change notification settings - Fork 588
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
remove overriding the grid sx #4982
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (2)
Line range hint
42-89
: Consider extracting grid item rendering logic to a separate component.The GridView component has multiple responsibilities: managing the grid container, header, and individual grid items. Consider extracting the grid item rendering logic (the mapping over propertiesAsArray) into a separate component for better maintainability and reusability.
Example refactor:
interface GridItemProps { property: any; // Replace with proper type path: string; data: any; // Replace with proper type parentProps: ViewPropsType; parentSchema: ObjectSchemaType; width: number; height: number; } function GridItem({ property, path, data, parentProps, parentSchema, width, height }: GridItemProps) { const { id, view = {} } = property; const { alignX, alignY, align_x, align_y, space } = view; const itemPath = getPath(path, id); const baseItemProps: BoxProps = { sx: { justifySelf: alignX || align_x || "unset", alignSelf: alignY || align_y || "unset", maxHeight: parentProps.orientation === "vertical" ? spaceToHeight(space, height) : undefined, width: "100%", boxSizing: "border-box", }, key: id, }; return ( <Box {...getProps( { ...parentProps, schema: property, layout: { width, height }, }, "item", baseItemProps )} > <DynamicIO {...parentProps} schema={property} path={itemPath} data={data?.[id]} parentSchema={parentSchema} relativePath={id} /> </Box> ); }
Line range hint
42-89
: Consider implementing React.memo for performance optimization.Since the grid items are rendered in a loop, wrapping the GridItem component (after extraction) with React.memo could prevent unnecessary re-renders when only individual items change.
Example implementation:
const MemoizedGridItem = React.memo(GridItem, (prevProps, nextProps) => { // Custom comparison logic if needed return false; });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
🔇 Additional comments (1)
app/packages/core/src/plugins/SchemaIO/components/GridView.tsx (1)
42-42
: LGTM! Removal of hardcoded sx props improves maintainability.The change to rely solely on
getComponentProps
for the container Box is a good approach as it prevents style conflicts and makes the component more maintainable.Let's verify that
getComponentProps
properly handles all necessary container styles:✅ Verification successful
Let me try a different approach to find the
getComponentProps
implementation.
Let me try to find the implementation of
getComponentProps
function since we found its usage but not the actual implementation.
Now I have enough information to provide a final response about the review comment.
LGTM! The change to rely on getComponentProps is safe and maintains styling consistency.
The removal of hardcoded
sx
props in favor of usinggetComponentProps
is a good approach because:
getComponentProps
is a utility function that properly merges component props from the schema's view configuration (schema.view.componentsProps[id]
) with any base props.- The function is widely used across all SchemaIO components for consistent prop handling.
- The container's styles can still be customized through the schema's view configuration, making it more maintainable and centralized.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for getComponentProps implementation and its style handling ast-grep --pattern 'function getComponentProps($_) { $$$ }'Length of output: 63
Script:
#!/bin/bash # Search for getComponentProps using ripgrep for more flexibility rg "getComponentProps" -A 5 -B 5Length of output: 127786
Script:
#!/bin/bash # Search for getComponentProps implementation in utils/index.ts cat app/packages/core/src/plugins/SchemaIO/utils/index.tsLength of output: 2487
What changes are proposed in this pull request?
This causes regression in all GridViews - avoid overriding the spread props
How is this patch tested? If it is not, please explain why.
(Details)
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
GridView
component by removing thesx
prop from the outerBox
, enhancing maintainability while preserving layout and rendering behavior.