on e47013d help sign in
bridge/src/form/Condition.js
11 lines 357 B history raw
1import { useField } from 'react-final-form';
3// inspired by: https://codesandbox.io/s/lm4p3m92q
4// renders childen if the relevant field's value is the test value
5export default function Condition({ when, is, children }) {
6 const {
7 input: { value },
8 } = useField(when, { subscription: { value: true } });
10 return value === is ? children : null;