Code Monkey home page Code Monkey logo

Comments (5)

pd4d10 avatar pd4d10 commented on July 18, 2024

Could you give a reproductive example, such as a GitHub repo or https://codesandbox.io/

from hashmd.

 avatar commented on July 18, 2024

https://codesandbox.io/s/amazing-hugle-hmwhk

from hashmd.

pd4d10 avatar pd4d10 commented on July 18, 2024

It seems caused by Form.Item:

https://ant.design/components/form-cn/#API

被设置了 name 属性的 Form.Item 包装的控件,表单控件会自动添加 value(或 valuePropName 指定的其他属性) onChange(或 trigger 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:

你不再需要也不应该用 onChange 来做数据收集同步(你可以使用 Form 的 onValuesChange),但还是可以继续监听 onChange 事件。

你不能用控件的 value 或 defaultValue 等属性来设置表单域的值,默认值可以用 Form 里的 initialValues 来设置。注意 initialValues 不能被 setState 动态更新,你需要用 setFieldsValue 来更新。

你不应该用 setState,可以使用 form.setFieldsValue 来动态改变表单值。

from hashmd.

 avatar commented on July 18, 2024

OK,then can't be used together.

from hashmd.

pd4d10 avatar pd4d10 commented on July 18, 2024

其实是可以的,有两种方法

  1. 去掉 name,变成不受控组件
  2. 按照文档里说的设置 initialValues,不要传 undefined 作为 valueEditor

这个错误是因为传了 undefined 过来,导致 CodeMirror 内部调用 split 方法报错了。

from hashmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.