简体   繁体   English

React-final-form中是否有FormSection(reduxForm)的替代品? 如果不是,如何以最终形式实施

[英]Is there a replacement for FormSection(reduxForm) in React-final-form. If not how to implement it in react-final-form

I'm migrating from Redux form to react final form. 我正在从Redux表单迁移到最终表单。 Is there a replacement for FormSection of ReduxForm in react-final-form? 在React-final-form中是否可以替代ReduxForm的FormSection?

I saw a solution here by using the dot notation. 我在这里看到了使用点符号的解决方案。 However, my app might have a lot of nested formsections. 但是,我的应用程序可能有很多嵌套的窗体部分。 So its not possible to determine and add the names accordingly. 因此,不可能确定并相应地添加名称。 So is there an replaceable implementation for Formsection in react-final-form? 那么在React-final-form中是否存在Formsection的可替换实现?

I'm currently trying out using a context. 我目前正在尝试使用上下文。 However this requires changing the 'name' prop to ${val}.${prevName} everywhere. 但是,这需要在各处将“名称” ${val}.${prevName}更改为${val}.${prevName} Thus, it would be better to have an easier implementation if possible 因此,如果可能的话,最好是更容易实现

Sort of. 有点。 There are two approaches: 有两种方法:

  • Reusable Field Groups – if you know the exact fields you want to reuse under some prefix 可重用字段组 –如果您知道要在某个前缀下重用的确切字段
  • Prefixed Fields – if you want to prefix any arbitrary set of fields ( but you must use a modified Field component ) 前缀字段 –如果要为任意任意字段添加前缀( 但必须使用修改后的Field组件

The latter example I just wrote as a response to this question. 我刚刚写的后一个示例就是对此问题的回答。 These are not included in the library because they are so relatively simple to add to your codebase manually. 这些不包含在库中,因为它们相对容易手动添加到您的代码库中。

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM