Skip to content

Commit

Permalink
fix(form): formItem 的 props 改为 Partial
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud committed Jul 13, 2023
1 parent 1dd9ede commit c55761f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/packages/formitem/formitem.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ const defaultProps = {
errorMessageAlign: 'left',
} as FormItemProps

export type FieldProps = typeof defaultProps & Partial<BaseFormField>

export class FormItem extends React.Component<
FieldProps,
Partial<FormItemProps>,
{ resetCount: number }
> {
static defaultProps = defaultProps
Expand All @@ -52,7 +50,7 @@ export class FormItem extends React.Component<

private componentRef: React.RefObject<any>

constructor(props: FieldProps) {
constructor(props: FormItemProps) {
super(props)
this.componentRef = React.createRef()
this.state = {
Expand All @@ -74,7 +72,7 @@ export class FormItem extends React.Component<
// children添加value属性和onChange事件
getControlled = (children: React.ReactElement) => {
const { setFieldsValue, getFieldValue } = this.context
const { name } = this.props
const { name = '' } = this.props

if (children?.props?.defaultValue) {
console.warn('通过 initialValue 设置初始值')
Expand Down
8 changes: 3 additions & 5 deletions src/packages/formitem/formitem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ const defaultProps = {
errorMessageAlign: 'left',
} as FormItemProps

export type FieldProps = typeof defaultProps & Partial<BaseFormField>

export class FormItem extends React.Component<
FieldProps,
Partial<FormItemProps>,
{ resetCount: number }
> {
static defaultProps = defaultProps
Expand All @@ -52,7 +50,7 @@ export class FormItem extends React.Component<

private componentRef: React.RefObject<any>

constructor(props: FieldProps) {
constructor(props: FormItemProps) {
super(props)
this.componentRef = React.createRef()
this.state = {
Expand All @@ -74,7 +72,7 @@ export class FormItem extends React.Component<
// children添加value属性和onChange事件
getControlled = (children: React.ReactElement) => {
const { setFieldsValue, getFieldValue } = this.context
const { name } = this.props
const { name = '' } = this.props

if (children?.props?.defaultValue) {
console.warn('通过 initialValue 设置初始值')
Expand Down

0 comments on commit c55761f

Please sign in to comment.