If using the new style context, re-declare this in your class to be the
React.ContextType
of your static contextType
.
Should be used with type annotation or static contextType.
static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>
根据 name
订阅 FieldSet
的值
根据 name
或者 model
订阅字段校验状态的更新
当参数是 Model
对象时不依赖 FormContext
,参数是字段名时必须在有 FormContext
的环境下使用。
根据 name
或者 model
订阅字段值的更新
创建一个 FieldArray
builder
数组元素的 builder 对象,可以是 field
、array
或者 set
的返回值
If set, this.context
will be set at runtime to the current value of the given Context.
Usage:
type MyContext = number
const Ctx = React.createContext<MyContext>(0)
class Foo extends React.Component {
static contextType = Ctx
context!: React.ContextType<typeof Ctx>
render () {
return <>My context's value: {this.context}</>;
}
}
创建一个异步校验函数
异步校验函数的实现
创建一个 Field
builder
Field
的默认值
创建一个 Form
builder,是最顶层的 builder 对象
Form
每个字段对应的 builder 对象,其值可以是 field
、array
或者 set
的返回值
判断一个校验函数是否是异步的,异步的校验函数必须使用 createAsyncValidator
创建
校验函数
创建一个 FieldSet
builder
FieldSet
每个字段对应的 builder 对象,其值可以是 field
、array
或者 set
的返回值
获取一个 Field
。
Model
模式下传入字符串类型的 field
时, validators
和 defaultValue
均无效。
字段名
默认值
校验函数数组
获取一个 Field
Field
对应的 model 对象,用于关联 Field
和 model;当 FormStrategy
是 Model
或渲染 FieldArray
的时候才能使用
创建一个 FieldArray
Model
模式下传入字符串类型的 field
时, validators
和 defaultValue
均无效。
字段名
校验函数数组
默认值
创建一个 FieldArray
FieldArray
对应的 model 对象,用于关联 FieldArray
和 model;当 FormStrategy
是 Model
的时候才能用
根据 name
或者 model
订阅 FieldArray
的更新
根据 name
或者 model
订阅 FieldArray
的更新
创建一个 FieldSet
Model
模式下传入字符串类型的 field
时, validators
无效。
字段名
校验函数数组
创建一个 FieldSet
model 对象
订阅 model
的校验状态
当参数是 Model
对象时不依赖 FormContext
,参数是字段名时必须在有 FormContext
的环境下使用。
订阅 model
的值。
当参数是 Model
对象时不依赖 FormContext
,参数是字段名时必须在有 FormContext
的环境下使用。
Subscribe value of form. Note that this hook might cause performance problem(s), use it with caution.
Return value of Form.useForm
Subscribe value of form. Note that this hook might cause performance problem(s), use it with caution.
Return value of Form.useForm
订阅 model
的校验状态
订阅 model
的值
订阅名为 name
的子 model 变更。
变更包括增加/删除该子 model,但不包括子 model 内部数据的变化。
订阅 child 的 FieldSetModel
child 的名字
Called immediately before mounting occurs, and before Component#render
.
Avoid introducing any side-effects or subscriptions in this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling Component#setState
generally does not trigger this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call Component#setState
here.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.
Called immediately before mounting occurs, and before Component#render
.
Avoid introducing any side-effects or subscriptions in this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling Component#setState
generally does not trigger this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call Component#setState
here.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
Runs before React applies the result of render
to the document, and
returns an object to be given to componentDidUpdate. Useful for saving
things such as scroll position before render
causes changes to it.
Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.
Called to determine whether the change in props and state should trigger a re-render.
Component
always returns true.
PureComponent
implements a shallow comparison on props and state and returns true if any
props or states have changed.
If false is returned, Component#render
, componentWillUpdate
and componentDidUpdate
will not be called.
Generated using TypeDoc
https://reactjs.org/docs/legacy-context.html