mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-24 04:15:54 +08:00
chore: upgrade deps
style(prettier): format code style
This commit is contained in:
@@ -17,7 +17,7 @@ describe('AutoComplete Search', () => {
|
||||
|
||||
it('should update value when dropdown clicked', () => {
|
||||
let value = ''
|
||||
const wrapper = mount(<AutoComplete options={mockOptions} onChange={(val) => (value = val)} />)
|
||||
const wrapper = mount(<AutoComplete options={mockOptions} onChange={val => (value = val)} />)
|
||||
wrapper.find('input').at(0).simulate('focus')
|
||||
wrapper.find('.item').at(0).simulate('click', nativeEvent)
|
||||
expect(value).toEqual('london')
|
||||
@@ -26,7 +26,7 @@ describe('AutoComplete Search', () => {
|
||||
it('should ignore events when disabled', () => {
|
||||
let value = ''
|
||||
const wrapper = mount(
|
||||
<AutoComplete disabled options={mockOptions} onChange={(val) => (value = val)} />,
|
||||
<AutoComplete disabled options={mockOptions} onChange={val => (value = val)} />,
|
||||
)
|
||||
wrapper.find('input').at(0).simulate('focus')
|
||||
wrapper.find('.item').at(0).simulate('click', nativeEvent)
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Checkbox Group', () => {
|
||||
it('should change value after click', () => {
|
||||
let value = ['sydney']
|
||||
const wrapper = mount(
|
||||
<Checkbox.Group value={['sydney']} onChange={(val) => (value = val)}>
|
||||
<Checkbox.Group value={['sydney']} onChange={val => (value = val)}>
|
||||
<Checkbox value="sydney">Sydney</Checkbox>
|
||||
<Checkbox value="beijing">BeiJing</Checkbox>
|
||||
</Checkbox.Group>,
|
||||
@@ -51,7 +51,7 @@ describe('Checkbox Group', () => {
|
||||
it('should ignore events when disabled', () => {
|
||||
let value = ['sydney']
|
||||
const wrapper = mount(
|
||||
<Checkbox.Group disabled value={['sydney']} onChange={(val) => (value = val)}>
|
||||
<Checkbox.Group disabled value={['sydney']} onChange={val => (value = val)}>
|
||||
<Checkbox value="sydney">Sydney</Checkbox>
|
||||
<Checkbox value="beijing">BeiJing</Checkbox>
|
||||
</Checkbox.Group>,
|
||||
@@ -68,7 +68,7 @@ describe('Checkbox Group', () => {
|
||||
it('should throw error when value missing', () => {
|
||||
let errorMessage = ''
|
||||
const Group = Checkbox.Group as any
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
mount(
|
||||
<Group>
|
||||
<Checkbox value="sydney">Sydney</Checkbox>
|
||||
@@ -82,7 +82,7 @@ describe('Checkbox Group', () => {
|
||||
|
||||
it('should throw error when set check prop in group', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
mount(
|
||||
<Checkbox.Group value={[]}>
|
||||
<Checkbox value="sydney" checked>
|
||||
|
||||
@@ -33,7 +33,7 @@ const CheckboxGroup: React.FC<React.PropsWithChildren<CheckboxGroupProps>> = ({
|
||||
}
|
||||
|
||||
const updateState = (val: string, checked: boolean) => {
|
||||
const removed = selfVal.filter((v) => v !== val)
|
||||
const removed = selfVal.filter(v => v !== val)
|
||||
const next = checked ? [...removed, val] : removed
|
||||
setSelfVal(next)
|
||||
onChange && onChange(next)
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Code', () => {
|
||||
|
||||
it('should alert warning when use bash', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
|
||||
mount(<Code bash>code</Code>)
|
||||
expect(errorMessage.toLowerCase()).toContain('deprecated')
|
||||
@@ -40,7 +40,7 @@ describe('Code', () => {
|
||||
|
||||
it('should alert warning when use darkBash', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
|
||||
mount(<Code darkBash>code</Code>)
|
||||
expect(errorMessage.toLowerCase()).toContain('deprecated')
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('Collapse', () => {
|
||||
it('should throw error when title missing', () => {
|
||||
const Component = Collapse as any
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
|
||||
mount(<Component subtitle="subtitle">content</Component>)
|
||||
expect(errorMessage.toLowerCase()).not.toEqual('')
|
||||
|
||||
@@ -28,7 +28,7 @@ const CollapseGroup: React.FC<React.PropsWithChildren<CollapseGroupProps>> = ({
|
||||
const theme = useTheme()
|
||||
const [state, setState, stateRef] = useCurrentState<Array<number>>([])
|
||||
const updateValues = (currentIndex: number, nextState: boolean) => {
|
||||
const hasChild = stateRef.current.find((val) => val === currentIndex)
|
||||
const hasChild = stateRef.current.find(val => val === currentIndex)
|
||||
if (accordion) {
|
||||
if (nextState) return setState([currentIndex])
|
||||
return setState([])
|
||||
@@ -41,7 +41,7 @@ const CollapseGroup: React.FC<React.PropsWithChildren<CollapseGroupProps>> = ({
|
||||
if (hasChild) return
|
||||
return setState([...stateRef.current, currentIndex])
|
||||
}
|
||||
setState(stateRef.current.filter((item) => item !== currentIndex))
|
||||
setState(stateRef.current.filter(item => item !== currentIndex))
|
||||
}
|
||||
|
||||
const initialValue = useMemo<CollapseConfig>(
|
||||
|
||||
@@ -45,7 +45,7 @@ const Collapse: React.FC<React.PropsWithChildren<CollapseProps>> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (!values.length) return
|
||||
const isActive = !!values.find((item) => item === index)
|
||||
const isActive = !!values.find(item => item === index)
|
||||
setVisible(isActive)
|
||||
}, [values.join(',')])
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Fieldset Group', () => {
|
||||
|
||||
it('should throw error when value duplicated', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
|
||||
mount(
|
||||
<Fieldset.Group value="two">
|
||||
@@ -50,7 +50,7 @@ describe('Fieldset Group', () => {
|
||||
|
||||
it('should throw error when label missing', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
|
||||
mount(
|
||||
<Fieldset.Group value="one">
|
||||
|
||||
@@ -30,7 +30,7 @@ const FieldsetGroup: React.FC<React.PropsWithChildren<FieldsetGroupProps>> = ({
|
||||
const [items, setItems, ref] = useCurrentState<FieldItem[]>([])
|
||||
|
||||
const register = (newItem: FieldItem) => {
|
||||
const hasItem = ref.current.find((item) => item.value === newItem.value)
|
||||
const hasItem = ref.current.find(item => item.value === newItem.value)
|
||||
if (hasItem) {
|
||||
useWarning('The "value" of each "Fieldset" must be unique.', 'Fieldset')
|
||||
}
|
||||
@@ -58,7 +58,7 @@ const FieldsetGroup: React.FC<React.PropsWithChildren<FieldsetGroupProps>> = ({
|
||||
<FieldsetContext.Provider value={providerValue}>
|
||||
<div className={` ${className}`} {...props}>
|
||||
<div className="group">
|
||||
{items.map((item) => (
|
||||
{items.map(item => (
|
||||
<button
|
||||
onClick={() => clickHandle(item.value)}
|
||||
key={item.value}
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('Tree', () => {
|
||||
})
|
||||
|
||||
it('should show extra messages', () => {
|
||||
const files = mockFiles.map((item) => ({ ...item, extra: 'extra' }))
|
||||
const files = mockFiles.map(item => ({ ...item, extra: 'extra' }))
|
||||
const wrapper = mount(<Tree value={files} />)
|
||||
const firstName = wrapper.find('.name').at(0)
|
||||
expect(firstName.text()).toContain('extra')
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Input, useInput } from 'components'
|
||||
describe('UseInput', () => {
|
||||
it('should follow change with use-input', () => {
|
||||
let log = ''
|
||||
const logSpy = jest.spyOn(console, 'log').mockImplementation((msg) => (log = msg))
|
||||
const logSpy = jest.spyOn(console, 'log').mockImplementation(msg => (log = msg))
|
||||
const MockInput: React.FC<{ value?: string }> = ({ value }) => {
|
||||
const { state, setState, bindings } = useInput('')
|
||||
useEffect(() => {
|
||||
|
||||
@@ -25,7 +25,7 @@ const InputPassword = React.forwardRef<
|
||||
useImperativeHandle(ref, () => inputRef.current)
|
||||
|
||||
const iconClickHandler = () => {
|
||||
setVisible((v) => !v)
|
||||
setVisible(v => !v)
|
||||
/* istanbul ignore next */
|
||||
if (inputRef && inputRef.current) {
|
||||
inputRef.current.focus()
|
||||
|
||||
@@ -95,7 +95,7 @@ describe('Modal', () => {
|
||||
const wrapper = mount(
|
||||
<Modal open={true} onClose={closeHandler}>
|
||||
<Modal.Title>Modal</Modal.Title>
|
||||
<Modal.Action passive onClick={(e) => e.close()}>
|
||||
<Modal.Action passive onClick={e => e.close()}>
|
||||
Close
|
||||
</Modal.Action>
|
||||
</Modal>,
|
||||
|
||||
@@ -47,7 +47,7 @@ const getCurrentColor = (
|
||||
const colorKeys = Object.keys(colors)
|
||||
if (colorKeys.length === 0) return defaultColors[type]
|
||||
|
||||
const customColorKey = colorKeys.find((key) => ratio <= +key)
|
||||
const customColorKey = colorKeys.find(key => ratio <= +key)
|
||||
if (!customColorKey || Number.isNaN(+customColorKey)) return defaultColors[type]
|
||||
return colors[+customColorKey]
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('Radio Group', () => {
|
||||
|
||||
it('should trigger events in group', () => {
|
||||
let value = ''
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(
|
||||
<Radio.Group onChange={changeHandler}>
|
||||
<Radio value="1">Option 1</Radio>
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('Select', () => {
|
||||
|
||||
it('should trigger events when option changed', async () => {
|
||||
let value = ''
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(
|
||||
<Select onChange={changeHandler}>
|
||||
<Select.Option value="1">1</Select.Option>
|
||||
@@ -68,7 +68,7 @@ describe('Select', () => {
|
||||
|
||||
it('should ignore option when option disabled', async () => {
|
||||
let value = ''
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(
|
||||
<Select onChange={changeHandler}>
|
||||
<Select.Option value="1">1</Select.Option>
|
||||
@@ -104,7 +104,7 @@ describe('Select', () => {
|
||||
|
||||
it('should be wraning when ident value missing', () => {
|
||||
let errorMessage = ''
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg) => (errorMessage = msg))
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(msg => (errorMessage = msg))
|
||||
const SelectOption = Select.Option as any
|
||||
const wrapper = mount(
|
||||
<Select>
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('Slider', () => {
|
||||
|
||||
it('should trigger events when click', async () => {
|
||||
let value = 0
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(<Slider initialValue={20} onChange={changeHandler} />)
|
||||
wrapper.find('.slider').simulate('click', {
|
||||
...nativeEvent,
|
||||
@@ -59,7 +59,7 @@ describe('Slider', () => {
|
||||
|
||||
it('should trigger events when drag', async () => {
|
||||
let value = 0
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(<Slider initialValue={0} onChange={changeHandler} />)
|
||||
const dot = wrapper.find('.dot').getDOMNode() as HTMLDivElement
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('Slider', () => {
|
||||
|
||||
it('should ignore events when disabled', async () => {
|
||||
let value = 0
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(<Slider initialValue={0} disabled onChange={changeHandler} />)
|
||||
const dot = wrapper.find('.dot').getDOMNode() as HTMLDivElement
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('Slider', () => {
|
||||
|
||||
it('should move unit length is step', async () => {
|
||||
let value = 0
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(<Slider step={10} onChange={changeHandler} />)
|
||||
const dot = wrapper.find('.dot').getDOMNode() as HTMLDivElement
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('Slider', () => {
|
||||
|
||||
it('should return the specified when the limit is exceeded', () => {
|
||||
let value = 0
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(<Slider min={10} max={20} onChange={changeHandler} />)
|
||||
const dot = wrapper.find('.dot').getDOMNode() as HTMLDivElement
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ const Slider: React.FC<React.PropsWithChildren<SliderProps>> = ({
|
||||
}
|
||||
|
||||
const updateValue = useCallback(
|
||||
(offset) => {
|
||||
offset => {
|
||||
const currentValue = getValue(max, min, step, offset, sideWidthRef.current)
|
||||
setValue(currentValue)
|
||||
onChange && onChange(currentValue)
|
||||
|
||||
@@ -17,7 +17,7 @@ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
||||
export type TableHeadProps = Props & typeof defaultProps & NativeAttrs
|
||||
|
||||
const makeColgroup = (width: number, columns: Array<TableColumnItem>) => {
|
||||
const unsetWidthCount = columns.filter((c) => !c.width).length
|
||||
const unsetWidthCount = columns.filter(c => !c.width).length
|
||||
const customWidthTotal = columns.reduce((pre, current) => {
|
||||
return current.width ? pre + current.width : pre
|
||||
}, 0)
|
||||
@@ -34,7 +34,7 @@ const makeColgroup = (width: number, columns: Array<TableColumnItem>) => {
|
||||
|
||||
const TableHead: React.FC<TableHeadProps> = ({ columns, width }) => {
|
||||
const theme = useTheme()
|
||||
const isScalableWidth = useMemo(() => columns.find((item) => !!item.width), [columns])
|
||||
const isScalableWidth = useMemo(() => columns.find(item => !!item.width), [columns])
|
||||
const colgroup = useMemo(() => {
|
||||
if (!isScalableWidth) return <colgroup />
|
||||
return makeColgroup(width, columns)
|
||||
|
||||
@@ -49,7 +49,7 @@ const Table: React.FC<React.PropsWithChildren<TableProps>> = ({
|
||||
const [columns, setColumns, columnsRef] = useCurrentState<Array<TableColumnItem>>([])
|
||||
const [selfData, setSelfData, dataRef] = useCurrentState<Array<TableColumnItem>>([])
|
||||
const appendColumn = (column: TableColumnItem) => {
|
||||
const pureCurrent = columnsRef.current.filter((item) => item.value !== column.value)
|
||||
const pureCurrent = columnsRef.current.filter(item => item.value !== column.value)
|
||||
setColumns([...pureCurrent, column])
|
||||
}
|
||||
const removeRow = (rowIndex: number) => {
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('Tabs', () => {
|
||||
|
||||
it('should trigger events when tab changed', () => {
|
||||
let value = ''
|
||||
const changeHandler = jest.fn().mockImplementation((val) => (value = val))
|
||||
const changeHandler = jest.fn().mockImplementation(val => (value = val))
|
||||
const wrapper = mount(
|
||||
<Tabs initialValue="1" onChange={changeHandler}>
|
||||
<Tabs.Item label="label1" value="1">
|
||||
|
||||
@@ -32,14 +32,14 @@ const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
|
||||
const [tabs, setTabs, tabsRef] = useCurrentState<Array<TabsLabelItem>>([])
|
||||
|
||||
const register = (next: TabsLabelItem) => {
|
||||
const hasItem = tabsRef.current.find((item) => item.value === next.value)
|
||||
const hasItem = tabsRef.current.find(item => item.value === next.value)
|
||||
if (hasItem) {
|
||||
useWarning('The "value" of each "Tabs.Item" must be unique.', 'Tabs')
|
||||
}
|
||||
setTabs([...tabsRef.current, next])
|
||||
}
|
||||
const unregister = (next: TabsLabelItem) => {
|
||||
const nextTabs = tabsRef.current.filter((item) => item.value !== next.value)
|
||||
const nextTabs = tabsRef.current.filter(item => item.value !== next.value)
|
||||
setTabs([...nextTabs])
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Textarea', () => {
|
||||
|
||||
it('should trigger events when textarea changed', () => {
|
||||
let value = ''
|
||||
const handler = jest.fn().mockImplementation((e) => (value = e.target.value))
|
||||
const handler = jest.fn().mockImplementation(e => (value = e.target.value))
|
||||
const wrapper = mount(<Textarea onChange={handler} />)
|
||||
wrapper.find('textarea').simulate('change', { target: { value: 'test-value' } })
|
||||
expect(handler).toHaveBeenCalled()
|
||||
|
||||
@@ -59,7 +59,7 @@ const useToasts = (): [Array<Toast>, (t: Toast) => void] => {
|
||||
|
||||
const cancel = (id: string, delay: number) => {
|
||||
updateToasts((currentToasts: Array<ToastWithID>) => {
|
||||
return currentToasts.map((item) => {
|
||||
return currentToasts.map(item => {
|
||||
if (item.id !== id) return item
|
||||
return { ...item, willBeDestroy: true }
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('Toggle', () => {
|
||||
|
||||
it('should trigger events when toggle changed', async () => {
|
||||
let checked = false
|
||||
const changeHandler = jest.fn().mockImplementation((e) => (checked = e.target.checked))
|
||||
const changeHandler = jest.fn().mockImplementation(e => (checked = e.target.checked))
|
||||
const wrapper = mount(<Toggle onChange={changeHandler} />)
|
||||
|
||||
wrapper.find('input').simulate('change', {
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('UseCurrentState', () => {
|
||||
const { result } = renderHook(() => useCurrentState(0))
|
||||
expect(result.current[0]).toEqual(0)
|
||||
|
||||
act(() => result.current[1]((pre) => pre + 10))
|
||||
act(() => result.current[1](pre => pre + 10))
|
||||
expect(result.current[0]).toEqual(10)
|
||||
expect(result.current[2].current).toEqual(10)
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ export const getId = () => {
|
||||
}
|
||||
|
||||
export const hasChild = (children: ReactNode | undefined, child: React.ElementType): boolean => {
|
||||
const types = React.Children.map(children, (item) => {
|
||||
const types = React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return null
|
||||
return item.type
|
||||
})
|
||||
@@ -18,7 +18,7 @@ export const pickChild = (
|
||||
targetChild: React.ElementType,
|
||||
): [ReactNode | undefined, ReactNode | undefined] => {
|
||||
let target: ReactNode[] = []
|
||||
const withoutTargetChildren = React.Children.map(children, (item) => {
|
||||
const withoutTargetChildren = React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return item
|
||||
if (item.type === targetChild) {
|
||||
target.push(item)
|
||||
@@ -38,7 +38,7 @@ export const pickChildByProps = (
|
||||
value: any,
|
||||
): [ReactNode | undefined, ReactNode | undefined] => {
|
||||
let target: ReactNode[] = []
|
||||
const withoutPropChildren = React.Children.map(children, (item) => {
|
||||
const withoutPropChildren = React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return null
|
||||
if (!item.props) return item
|
||||
if (item.props[key] === value) {
|
||||
@@ -66,11 +66,11 @@ export const setChildrenProps = (
|
||||
const allowAll = targetComponents.length === 0
|
||||
const clone = (child: React.ReactElement, props = {}) => React.cloneElement(child, props)
|
||||
|
||||
return React.Children.map(children, (item) => {
|
||||
return React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return item
|
||||
if (allowAll) return clone(item, props)
|
||||
|
||||
const isAllowed = targetComponents.find((child) => child === item.type)
|
||||
const isAllowed = targetComponents.find(child => child === item.type)
|
||||
if (isAllowed) return clone(item, props)
|
||||
return item
|
||||
})
|
||||
@@ -85,12 +85,12 @@ export const setChildrenIndex = (
|
||||
const clone = (child: React.ReactElement, props = {}) => React.cloneElement(child, props)
|
||||
let index = 0
|
||||
|
||||
return React.Children.map(children, (item) => {
|
||||
return React.Children.map(children, item => {
|
||||
if (!React.isValidElement(item)) return item
|
||||
index = index + 1
|
||||
if (allowAll) return clone(item, { index })
|
||||
|
||||
const isAllowed = targetComponents.find((child) => child === item.type)
|
||||
const isAllowed = targetComponents.find(child => child === item.type)
|
||||
if (isAllowed) return clone(item, { index })
|
||||
index = index - 1
|
||||
return item
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface ZeitUiContextParams {
|
||||
const defaultParams: ZeitUiContextParams = {
|
||||
toasts: [],
|
||||
toastHovering: false,
|
||||
updateToasts: (t) => t,
|
||||
updateToasts: t => t,
|
||||
updateToastHoverStatus: () => {},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user