# Conditions for custom renderers

**URL:** <https://jsonforms.discourse.group/t/conditions-for-custom-renderers/1386>\
**Category:** General\
**Created:** [March 12, 2023, 12:25pm UTC](https://jsonforms.discourse.group/t/conditions-for-custom-renderers/1386 "2023-03-12T12:25:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![otter606](https://avatars.discourse-cdn.com/v4/letter/o/7ea924/32.png) [@otter606](https://jsonforms.discourse.group/u/otter606)\
**Post date:** [March 12, 2023, 12:25pm UTC](https://jsonforms.discourse.group/t/conditions-for-custom-renderers/1386/1 "2023-03-12T12:25:36Z")

</div>

Hello,  
I’m new to JsonForms - looks like a great project!  
I am exploring customRenderers and am puzzled why they don’t seem to obey conditions. I am wanting to display additional help text dependent on the value of some fields but couldn’t get the condition to work. I see the same problem in the seed project and can reproduce as below:

. For example:

1. Clone the seed project, install dependencies and start
2. Copy and paste the condition in uiSchema.json from ‘recurrence\_interval’ to ‘rating’ which has a custom renderer.
3. When setting recurrence to ‘Never’ the recurrence\_interval control gets hidden, but the rating control is still visible.  
Is this a bug or am I missing something, and do custom renderers need additional configuration to have conditions applied? If I copy and paste the condition into other fields (e.g due date, description) the conditions work just fine.  
Thanks!

This is what the rating control looks like

```auto
{
          "type": "Control",
          "scope": "#/properties/rating",
          "rule": {
            "effect": "HIDE",
            "condition": {
              "scope": "#/properties/recurrence",
              "expectedValue": "Never"
            }
          }
 }

```

---

<div class="post-metadata">

**Author:** ![lucas-koehler](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/lucas-koehler/32/336_2.png) [@lucas-koehler](https://jsonforms.discourse.group/u/lucas-koehler)\
**Post date:** [March 13, 2023, 11:17am UTC](https://jsonforms.discourse.group/t/conditions-for-custom-renderers/1386/2 "2023-03-13T11:17:16Z")

</div>

Hi @otter606 ,  
thanks for your interest in JsonForms 🙂

Rules are not applied automatically to controls - including custom controls - but the calculated enabled and visible state is supplied to controls in their props via the control’s appropriate higher order component.

Each control is then responsible itself to apply the visible and enabled props.

For instance, the vanilla renderer’s InputControl, gets the `visible` state as prop here: [jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub](https://github.com/eclipsesource/jsonforms/blob/2bbc64689cdf694daacac7ff5c1f5de6eb540849/packages/vanilla-renderers/src/controls/InputControl.tsx#L60)

This `visible` prop is then used to show or hide the control here: [jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub](https://github.com/eclipsesource/jsonforms/blob/2bbc64689cdf694daacac7ff5c1f5de6eb540849/packages/vanilla-renderers/src/controls/InputControl.tsx#L96)

The `visible` prop is injected into the InputControl via HOC `withJsonFormsControlProps` here: [jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub](https://github.com/eclipsesource/jsonforms/blob/2bbc64689cdf694daacac7ff5c1f5de6eb540849/packages/vanilla-renderers/src/controls/InputControl.tsx#L126)

In conclusion, you need to implement hiding/disabling your control based on the supplied `visible` resp. `enabled` props. The props are calculated considering the rules in the UI Schema.

I hope that helps,  
Lucas

---

<div class="post-metadata">

**Author:** ![otter606](https://avatars.discourse-cdn.com/v4/letter/o/7ea924/32.png) [@otter606](https://jsonforms.discourse.group/u/otter606)\
**Post date:** [March 13, 2023, 7:18pm UTC](https://jsonforms.discourse.group/t/conditions-for-custom-renderers/1386/3 "2023-03-13T19:18:08Z")

</div>

Hi Lucas  
Thanks for the quick reply! I see now, I thought it unlikely to be a bug but thanks for clarifying.  
Best wishes  
Richard
