I get this warning when I run my React.js front-end:
index.js:1446 Warning: Failed prop type: The prop `children` is marked as required in `InputAdornment`, but its value is `undefined`.
in InputAdornment (created by WithStyles(InputAdornment))
in WithStyles(InputAdornment) (at TopControls.js:101)
in div (created by InputBase)
in InputBase (created by Context.Consumer)
in WithFormControlContext(InputBase) (created by WithStyles(WithFormControlContext(InputBase)))
in WithStyles(WithFormControlContext(InputBase)) (created by Input)
in Input (created by WithStyles(Input))
in WithStyles(Input) (created by TextField)
in div (created by FormControl)
in FormControl (created by WithStyles(FormControl))
in WithStyles(FormControl) (created by TextField)
in TextField (at TopControls.js:91)
in div (created by Grid)
in Grid (created by WithStyles(Grid))
in WithStyles(Grid) (at TopControls.js:90)
in div (created by Grid)
in Grid (created by WithStyles(Grid))
in WithStyles(Grid) (at TopControls.js:89)
in div (at TopControls.js:22)
in TopControls (at BatchFlights.js:147)
in BatchFlights (created by WithStyles(BatchFlights))
in WithStyles(BatchFlights) (at App.js:23)
The lines 10-102 in TopControls.js
contain this code:
InputProps={{
startAdornment: <InputAdornment position="start"></InputAdornment>,
}}
Could someone please explain what is wrong and how can I avoid this warning?
When you write <InputAdornment position="start"></InputAdornment>
, you do not pass any children to InputAdornment (for example, I could write <InputAdornment position="start"><MyComponent /></InputAdornment>
if I wanted to pass MyComponent in InputAdornment's children
).
At the same time, props children
is specified as required
in InputAdornment's PropTypes
.
There are two ways to remove a warning:
required
specifier from its PropTypes
. children
to it as in the example above. Then PropType's
requirement will be met.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With