This repository was archived by the owner on Nov 8, 2025. It is now read-only.
Allow boxClassName to be a function#2
Open
matthieutirelli-pro wants to merge 1 commit intomxmul:masterfrom
Open
Allow boxClassName to be a function#2matthieutirelli-pro wants to merge 1 commit intomxmul:masterfrom
matthieutirelli-pro wants to merge 1 commit intomxmul:masterfrom
Conversation
Author
|
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 :) |
mxmul
suggested changes
Mar 14, 2022
Owner
mxmul
left a comment
There was a problem hiding this comment.
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.
| import React, { useState, useEffect, useRef, useCallback } from 'react' | ||
| import { largestRect } from 'rect-scaler' | ||
|
|
||
| type FunctionBoxClassNameType = (child: React.ReactNode) => string; |
Owner
There was a problem hiding this comment.
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?
mxmul
reviewed
Mar 14, 2022
| children: React.ReactNode | ||
| className?: string | ||
| boxClassName?: string | ||
| boxClassName?: string | FunctionBoxClassNameType |
Owner
There was a problem hiding this comment.
You could just inline the FunctionBoxClassNameType here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 :