当前位置:网站首页>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,
})
}
}
边栏推荐
- MySQL 默认隔离级别是RR,为什么阿里等大厂会改成RC?
- 你必需要了解的saas架构设计?
- HDU 2874 connections between cities
- Interpretation of afnetworking4.0 request principle
- Youxuan database participated in the compilation of the Research Report on database development (2022) of the China Academy of communications and communications
- 【ARXIV2203】CMX: Cross-Modal Fusion for RGB-X Semantic Segmentation with Transformers
- HDU 1914 the stable marriage problem
- CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?
- Activation functions sigmoid, tanh, relu in convolutional neural networks
- Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
猜你喜欢

Analyze the emotional elements contained in intelligent sweeping robot

App test process and test points

Driving the powerful functions of EVM and xcm, how subwallet enables Boca and moonbeam

With a monthly salary of 15.5K, he failed to start a business and was heavily in debt. How did he reverse the trend through software testing?

FreeRTOS个人笔记-任务通知
![(3.1) [Trojan horse synthesis technology]](/img/e7/0e09c1d1bac23022ead7478ea9898a.png)
(3.1) [Trojan horse synthesis technology]

From the basic concept of micro services to core components - explain and analyze through an example

Do you know several assertion methods commonly used by JMeter?

猿辅导技术进化论:助力教与学 构想未来学校

Interview fraud: there are companies that make money from interviews
随机推荐
Testcafe's positioning, operation of page elements, and verification of execution results
Test report don't step on the pit
这种动态规划你见过吗——状态机动态规划之股票问题(中)
RT based_ Distributed wireless temperature monitoring system based on thread
Leetcode 454. Adding four numbers II
Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
Redux basic syntax
list indices must be integers or slices, not tuple
在外包公司两年了,感觉快要废了
你必需要了解的saas架构设计?
Method of converting UI file to py file
FPGA: use PWM wave to control LED brightness
Configuration experiment of building virtual private network based on MPLS
Look at the experience of n-year software testing summarized by people who came over the test
阿里怎么用DDD来拆分微服务?
RT based_ Distributed wireless temperature monitoring system of thread (I)
HDU 3592 World Exhibition (differential constraint)
Anaconda common instructions
Automated test tool playwright (quick start)
Barbie q! How to analyze the new game app?