mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 20:25:29 +08:00
feat(collections): support filter children contanin array props
This commit is contained in:
@@ -38,9 +38,17 @@ export const pickChildByProps = (
|
||||
value: any,
|
||||
): [ReactNode | undefined, ReactNode | undefined] => {
|
||||
let target: ReactNode[] = []
|
||||
const isArray = Array.isArray(value)
|
||||
const withoutPropChildren = React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return null
|
||||
if (!item.props) return item
|
||||
if (isArray) {
|
||||
if (value.includes(item.props[key])) {
|
||||
target.push(item)
|
||||
return null
|
||||
}
|
||||
return item
|
||||
}
|
||||
if (item.props[key] === value) {
|
||||
target.push(item)
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user