SniberbS
Reactifluxβ€’4y agoβ€’
8 replies
Sniberb

πŸŽƒ Spookyberb πŸŽƒ – 12-59 Nov 3

Having a function at the parent level, is it possible to pass from the child a value parameter to the function while also passing another parameter from the parent? I want to pass a
limit
param from the parent, and a
value
param from the child

const isValid = (value, limit = 25) => value.length <= limit;

<ControlledInput validationFunction={isValid} />
const ControlledInput = ({ control, name, label, validationFunction }) => (
  <Controller
  ...
        onValueChange={(val) => {
          if (validationFunction(val)) {
            onChange(val);
          }
        }}
  ...
  />
);
Was this page helpful?