Skip to content

Instantly share code, notes, and snippets.

@jpomykala
Created October 20, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpomykala/ea762c3c9d6f2264b6d008001f11d9a7 to your computer and use it in GitHub Desktop.
Save jpomykala/ea762c3c9d6f2264b6d008001f11d9a7 to your computer and use it in GitHub Desktop.
method
onChangeShareValue = (newShareValue: number, ingredientRowIndex: number) => {
const {
values,
setValues
} = this.props;
const nextIngredients = [...values.ingredients];
nextIngredients[ingredientRowIndex].shareAmount = newShareValue;
setValues({...values, ingredients: [...nextIngredients]});
};
<Input
id={`ingredient_${id}_share`}
type="number"
name="ingredients"
value={value}
min="1"
onChange={(event) => {
const newValue = event.target.value;
this.onChangeShareValue(newValue, ingredientRowIndex);
}}
placeholder={valuePlaceholder}
/>
validationSchema: Yup.object().shape({
name: Yup.string().required(),
volume: Yup.number().max(50000).required(),
tax: Yup.number().min(0).max(100),
volumeType: Yup.string().required(),
packaging: Yup.string().required(),
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment