null input in props
tags: learning programming react
content
sometimes i see errors like this:
Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.
- it indicates some
inputisnull - in this case, i have:
<TextField
label="Coffee (g)"
value={recipeData.coffeeWeight}
disabled={readonly}
/>- and
recipeData.coffeeWeightmight benullorundefined - we just need to give it a default value
<TextField
label="Coffee (g)"
value={recipeData.coffeeWeight || ''}
disabled={readonly}
/>