-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow boxClassName to be a function #2
base: master
Are you sure you want to change the base?
Conversation
I'm not very used to Typescript, so i'm not really sure for the syntax of the interface, i hope this could contribute to your project :) |
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.
Thanks for the PR! There's one small nit I'd like addressed, but the problem makes sense and it's something I'd like to see solved.
@@ -1,10 +1,13 @@ | |||
import React, { useState, useEffect, useRef, useCallback } from 'react' | |||
import { largestRect } from 'rect-scaler' | |||
|
|||
type FunctionBoxClassNameType = (child: React.ReactNode) => string; |
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.
Could we avoid passing around and introspecting React nodes like this? The pattern is discouraged / deprecated
Maybe instead, we only pass the index of the child?
interface Props { | ||
children: React.ReactNode | ||
className?: string | ||
boxClassName?: string | ||
boxClassName?: string | FunctionBoxClassNameType |
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.
You could just inline the FunctionBoxClassNameType
here.
Hello !
Thanks for your project that we really appreciate.
We faced an issue on our project, we want to have a grid with items taking specific classes ( on our case, to hide them without destroying the children from our list )
I changed the code for the boxClassName to allow a function that use the children as argument to determine the classes to apply to the Grid Item.
On our case we use it that way for instance :