简体   繁体   中英

Issues with ag-grid and final-form

I'm struggling to create an editable grid with ag-grid. I've found that using both a renderer and editor where both have useField creates problems when removing rows with react-final-form-array.

Keep in mind that a renderer is the readonly/normal state of the cell while the editor is the edit view; Editor is only rendered while editing.

https://codesandbox.io/s/infallible-violet-joej4?file=/src/App.js

In the example above, you'll see that I've commented out the renderer and validation rules. Commenting out the renderer prevents me from displaying validation errors--on top of this, ag-grid destroys the useField, so my validations are also lost.

Naively, I thought form validation instead of field validation was the way to go, but again, I still require a custom renderer to display validations or metadata.

I then thought of creating a two dimensional array that has all of the useField cells but this causes "Rendered more hooks than during the previous render." errors. I'm not well versed in hooks but I don't see <Field> working either.

Thoughts?

Moved away from updating by cell, and instead updated by grid. This let ag-grid be the source of truth that updates final-form as needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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