Closed jspannu919 closed 4 months ago
@jspannu919 Seems like the sandbox link does work. Cna you please it so we can check :slightly_smiling_face: ?
You are using a react hook within the action. This will never work. Hooks can't be conditional and can be called only within functions.
If you wish to conditionally mutate props based on the form state, you need a custom component. Action are here to map strings to JS functions, not to handle some extra internal component logic.
I've created a very basic sample here: https://codesandbox.io/p/sandbox/data-driven-forms-example-forked-zp5yjt
We wrote a wrapper to re-evaluate action mapping on field re-render, at our end bcz we had use case where we send expressions from backend and use that to do things like disabling fields. Closing the issue. Thanks team!
Unlike resolveProps, actions are not getting re-evaluated when only the field is re-rendered as we don't re-evaluate action mapping in useFieldApi. Also, we remove the actions while preparing props in renderForm. Reproducer: https://codesandbox.io/p/sandbox/data-driven-forms-example-forked-zp5yjt?file=%2Fsrc%2FApp.js%3A44%2C35