当前位置:网站首页>Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
2022-07-28 05:08:00 【Jason–json】
antd Use form Components setFieldsValue Warning questions
Original warning :
Cannot use setFieldsValue until you use getFieldDecorator or getFieldProps to register it
It means :
In the use of “getFieldDecorator” or “getFieldProps” Before registering , Out of commission “setFieldsValue”
The explanation on the official website is like this
Be careful : Use getFieldsValue getFieldValue setFieldsValue Isochronous , It shall be ensured that the corresponding field Has been used getFieldDecorator Registered
I haven't understood it for a long time Baidu for a while ,this.props.form.form.setFieldsValue When transferring values, it can only be form The parameters used in ( That is getFieldDecorator Methods field) There is no the field It is not allowed to transmit more , Otherwise you will report an error
That is to say, we use setFildsValue Set up value It's worth it But not used
The actual scene
The value is passed from the parent page
componentWillReceiveProps = (next) => {
// console.log(next)
// console.log(this.props.Type)
if (this.props.ProductRecipientApply !== next.ProductRecipientApply) {
this.props.form.setFieldsValue({
SaleContractNo: next.ProductRecipientApply.SaleContractNo,
IsLetterAuthorization: next.ProductRecipientApply.IsLetterAuthorization,
AppEndTime: next.ProductRecipientApply.AppEndTime,
InnerOrderNo: next.ProductRecipientApply.InnerOrderNo,
})
}
}
render Use
render() {
const {
form: {
getFieldDecorator }, Type, ProductRecipientApply, ProductSubmitCommitment, LogList } = this.props;
const {
IsInnerSettleCheckbox, BoolArr, isSettle, isSell, CheckboxProductRecipientApply, DateCreated } = this.state;
console.log(ProductRecipientApply)
return (
<Row className="ProjectInformationForm_body">
{
Type === "LookAt" || Type === "Approval" ?
<Form layout='inline' className="ShowInfor">
<Col span={
6}><Form.Item
label=" Sell to the outside world ">{
ProductRecipientApply.IsOutsideSale ? ' yes ' : ' no '}</Form.Item></Col>
<Col span={
6}><Form.Item
label=" Sales Contract No ">{
ProductRecipientApply ? ProductRecipientApply.SaleContractNo : ''}</Form.Item></Col>
<Col span={
6}><Form.Item
label=" Delivery time ">{
DateCreated ? DateCreated : ''}</Form.Item></Col>
<Col span={
6}><Form.Item
label=" A genuine power of attorney is required ">{
ProductRecipientApply.IsLetterAuthorization === "1" ? ' yes ' : ' no '}</Form.Item></Col>
<Col span={
6}><Form.Item
label=" Internal settlement ">{
ProductRecipientApply.IsInnerSettle ? ' yes ' : ' no '}</Form.Item></Col>
<Col span={
6}><Form.Item
label=" Internal order number ">{
ProductRecipientApply ? ProductRecipientApply.InnerOrderNo : ''}</Form.Item></Col>
<Col span={
12}>
<Form.Item label=" Relevant attachments " >
{
ProductSubmitCommitment && ProductSubmitCommitment.map((value, index) => {
return <a
style={
{
marginRight: 10 }}
target="_blank"
key={
index}
href={
value.DownloadUrl}>{
index + 1}、{
value.FileName}</a>
})
}
</Form.Item>
</Col>
</Form>
: <Form layout='inline' className="ShowInput">{
/* edit */}
<Col span={
3}>
<Form.Item label=" Sell to the outside world ">
{
getFieldDecorator('IsOutsideSale', {
rules: [{
required: false }] })(
<Checkbox checked={
CheckboxProductRecipientApply} onChange={
(e) => this.CheckboxChangeTwo(e)} />
)}
</Form.Item>
</Col>
<Col span={
9}>
<Form.Item label=" Sales Contract No ">
{
getFieldDecorator('SaleContractNo', {
rules: [{
required: isSell ? true : false }] })(
<Input placeholder=" Please enter " onChange={
(e) => this.SaleContractNo(e)} />
)}
</Form.Item>
</Col>
<Col span={
6}>
<Form.Item label=" Delivery time ">
{
getFieldDecorator('AppEndTime', {
rules: [{
required: false }] })(
<Input disabled />
)}
</Form.Item>
</Col>
<Col span={
6}>
<Form.Item label=" A genuine power of attorney is required ">
{
getFieldDecorator('IsLetterAuthorization', {
rules: [{
required: false }] })(
<Select style={
{
color: '#333' }} allowClear placeholder=" Please select ">
{
!BoolArr ? '' : BoolArr.map((item, index) =>
(<Option key={
index} value={
item.DictCode}>{
item.DictName}</Option>)
)
}
</Select>
)}
</Form.Item>
</Col>
<Col span={
3}>
<Form.Item label=" Internal settlement ">
{
getFieldDecorator('IsInnerSettle', {
rules: [{
required: false }] })(
<Checkbox checked={
IsInnerSettleCheckbox} onChange={
(e) => this.CheckboxChangeOne(e)} />
)}
</Form.Item>
</Col>
<Col span={
9}>
<Form.Item label=" Internal order number ">
{
getFieldDecorator('InnerOrderNo', {
rules: [{
required: isSettle ? true : false }],
})(
<Input placeholder=" Please enter " onChange={
(e) => this.InnerOrderNo(e)} />
)}
</Form.Item>
</Col>
<Col span={
24}>
<Form.Item label=" Relevant attachments ">
{
ProductSubmitCommitment ?
(getFieldDecorator('ProductSubmitCommitment', {
rules: [{
required: false }] })(
<UploadFile
action={
allUrl.common.uploadFile}
cb={
this.props.getProductSubmitCommitment}
data={
{
BusinessType: 'DPM_ProductSubmitCommitment' }}
fileList={
ProductSubmitCommitment}
multiple={
true}
disabled={
false}
></UploadFile>
)) : ''
}
</Form.Item>
</Col>
</Form>
}
</Row>
)
}
The above code shows When Type be equal to LookAt when We didn't use setFieldsValue Set data All when the page is in view We don't use setFieldsValue Set up the data Code plus judgment
if (this.props.ProductRecipientApply !== next.ProductRecipientApply) {
if (this.props.Type !== "LookAt") {
// Set up setFieldsValue Need to use getFieldDecorator receive
this.props.form.setFieldsValue({
SaleContractNo: next.ProductRecipientApply.SaleContractNo,
IsLetterAuthorization: next.ProductRecipientApply.IsLetterAuthorization,
AppEndTime: next.ProductRecipientApply.AppEndTime,
InnerOrderNo: next.ProductRecipientApply.InnerOrderNo,
})
}
}
边栏推荐
- 【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention
- Leetcode 18. sum of four numbers
- Read the paper -- a CNN RNN framework for clip yield prediction
- 阿里怎么用DDD来拆分微服务?
- Duoyu security browser will improve the security mode and make users browse more safely
- Applet import project
- 数据库日期类型全部为0
- CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
- UI automation test farewell from now on, manual download browser driver, recommended collection
- MySQL(5)
猜你喜欢

Analyze the emotional elements contained in intelligent sweeping robot

阿里怎么用DDD来拆分微服务?

Data security is gradually implemented, and we must pay close attention to the source of leakage
![(manual) [sqli labs27, 27a] error echo, Boolean blind injection, filtered injection](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
(manual) [sqli labs27, 27a] error echo, Boolean blind injection, filtered injection

What SaaS architecture design do you need to know?

Research on the design of robot education in stem course

Microservice failure mode and building elastic system

【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers

Visual studio 2019 new OpenGL project does not need to reconfigure the environment

Inspire domestic students to learn robot programming education for children
随机推荐
从微服务基本概念到核心组件-通过一个实例来讲解和分析
在外包公司两年了,感觉快要废了
【CPU占用高】software_reporter_tool.exe
【CVPR2022】Multi-Scale High-Resolution Vision Transformer for Semantic Segmentation
【ARXIV2203】Efficient Long-Range Attention Network for Image Super-resolution
Microservice failure mode and building elastic system
MySQL(5)
After a year of unemployment, I learned to do cross-border e-commerce and earned 520000. Only then did I know that going to work really delayed making money!
Testcafe's positioning, operation of page elements, and verification of execution results
[daily question 1] 735. Planetary collision
How to send and receive reports through outlook in FastReport VCL?
【ARXIV2204】Simple Baselines for Image Restoration
Real intelligence has been certified by two of the world's top market research institutions and has entered the global camp of excellence
Test report don't step on the pit
Paper reading notes -- crop yield prediction using deep neural networks
Euler road / Euler circuit
Dynamic SQL and paging
Online sql to XML tool
FPGA:使用PWM波控制LED亮度
【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention