yury-dymov / react-autocomplete-input

Autocomplete input field for React
https://yury-dymov.github.io/react-autocomplete-input/
MIT License
199 stars 65 forks source link

Invalid prop 'Component' supplied when using a custom component #40

Closed jsheffers closed 4 years ago

jsheffers commented 4 years ago

I'm trying to implement this with the TextareaAutosize component from Material UI. I'm creating a functional component and including it. It works, however, it throws a warning in the console:

Warning: Failed prop type: Invalid prop `Component` supplied to `t`.

It seems to function properly. Should I be doing this a different way? Codesandbox with this replicated:

const CustomTextarea = forwardRef((props, ref) => (
  // If I don't forward the ref I get an error...
  <TextareaAutosize
    placeholder="Material-ui through custom component..."
    {...props}
    ref={ref}
  />
));

<TextInput
    Component={CustomTextarea}
    options={["One", "Two", "Three", "Four", "Five"]}
    onChange={handleChange}
    value={typingMessage}
/>

Full example: https://codesandbox.io/s/fervent-hamilton-8pt2z

yury-dymov commented 4 years ago
Component: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.func,
  ]),

This is current validation. Maybe something is missing but I don't have time to support this at the moment, so I will gladly review and merge PR.

Given that it is a warning, I would just ignore it for now. I don't plan do any significant changes here, so you should be good

silverwind commented 4 years ago

I guess PropTypes.elementType might solve it (added in prop-types@15.7.0).