mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 22:42:51 +08:00
Merge pull request #140 from unix/test
test: remove unused default-values
This commit is contained in:
@@ -4,14 +4,13 @@ import withDefaults from '../utils/with-defaults'
|
||||
interface Props {
|
||||
x: number
|
||||
y: number
|
||||
color?: string
|
||||
onCompleted?: Function
|
||||
onCompleted: () => void
|
||||
color: string
|
||||
}
|
||||
|
||||
const defaultProps = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
onCompleted: () => {},
|
||||
}
|
||||
|
||||
export type ButtonDrip = Props & typeof defaultProps
|
||||
|
||||
@@ -6,7 +6,7 @@ export interface FieldItem {
|
||||
}
|
||||
|
||||
export interface FieldsetConfig {
|
||||
register: (item: FieldItem) => void
|
||||
register?: (item: FieldItem) => void
|
||||
currentValue: string
|
||||
inGroup: boolean
|
||||
}
|
||||
@@ -14,7 +14,6 @@ export interface FieldsetConfig {
|
||||
const defaultContext = {
|
||||
inGroup: false,
|
||||
currentValue: '',
|
||||
register: () => {},
|
||||
}
|
||||
|
||||
export const FieldsetContext = React.createContext<FieldsetConfig>(defaultContext)
|
||||
|
||||
@@ -25,18 +25,18 @@ const FieldsetGroup: React.FC<React.PropsWithChildren<FieldsetGroupProps>> = Rea
|
||||
const [selfVal, setSelfVal] = useState<string>(value)
|
||||
const [items, setItems, ref] = useCurrentState<FieldItem[]>([])
|
||||
|
||||
const register = useCallback((newItem: FieldItem) => {
|
||||
const register = (newItem: FieldItem) => {
|
||||
const hasItem = ref.current.find(item => item.value === newItem.value)
|
||||
if (hasItem) {
|
||||
useWarning('The "value" of each "Fieldset" must be unique.', 'Fieldset')
|
||||
}
|
||||
setItems([...ref.current, newItem])
|
||||
}, [])
|
||||
}
|
||||
|
||||
const providerValue = useMemo(() => ({
|
||||
currentValue: selfVal,
|
||||
inGroup: true,
|
||||
register: () => register,
|
||||
register,
|
||||
}), [selfVal])
|
||||
|
||||
const clickHandle = useCallback((nextValue: string) => {
|
||||
|
||||
@@ -47,8 +47,7 @@ const Fieldset: React.FC<React.PropsWithChildren<FieldsetProps>> = React.memo(({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const r: any = register({ value, label })
|
||||
r({ value, label })
|
||||
register && register({ value, label })
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import React from 'react'
|
||||
|
||||
export interface TreeConfig {
|
||||
onFileClick: (path: string) => void
|
||||
onFileClick?: (path: string) => void
|
||||
initialExpand: boolean
|
||||
isImperative: boolean
|
||||
}
|
||||
|
||||
const defaultContext = {
|
||||
onFileClick: () => {},
|
||||
initialExpand: false,
|
||||
isImperative: false,
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const TreeFile: React.FC<React.PropsWithChildren<TreeFileProps>> = ({
|
||||
const currentPath = useMemo(() => makeChildPath(name, parentPath), [])
|
||||
const clickHandler = (event: React.MouseEvent) => {
|
||||
stopPropagation(event)
|
||||
onFileClick(currentPath)
|
||||
onFileClick && onFileClick(currentPath)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,7 @@ const ModalAction: React.FC<ModalActionProps> = React.memo(({
|
||||
const clickHandler = (event: MouseEvent<HTMLButtonElement>) => {
|
||||
if (disabled) return
|
||||
const actionEvent = Object.assign({}, event, {
|
||||
close,
|
||||
close: () => close && close(),
|
||||
})
|
||||
onClick && onClick(actionEvent)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import React from 'react'
|
||||
|
||||
export interface ModalConfig {
|
||||
close: () => void
|
||||
close?: () => void
|
||||
}
|
||||
|
||||
const defaultContext = {
|
||||
close: () => {},
|
||||
}
|
||||
|
||||
export const ModalContext = React.createContext<ModalConfig>(defaultContext)
|
||||
|
||||
Reference in New Issue
Block a user