Hello,
The ButtonBase component shouldn't trigger a warning when passing a value to its component prop.
A warning is triggered : Warning: Failed prop type: Invalid prop component supplied to ButtonBase.
https://codesandbox.io/s/w6ln223vz5
| Tech | Version |
|--------------|---------|
| Material-UI | v1.2.1 |
| React | v16.3.2 |
@jgoux It's just a warning. I think that it comes from this line:
let Link = forwardRef(({ innerRef, ...props }, ref) => (
https://github.com/reach/router/blob/653f8e89e62190a6ae599f119105c3b5e608c690/src/index.js#L371
https://codesandbox.io/s/r5qm6469yq
Indeed! I'm ok with this solution, thanks a lot Olivier. 馃槈
Here we are, it's an object!
const FancyButton = React.forwardRef((props, ref) => (
<button ref={ref} className="FancyButton">
{props.children}
</button>
));
console.log(typeof FancyButton); // object
So I believe we have to update all the prop-types:
https://github.com/mui-org/material-ui/blob/238d6c35743322fc75a8bacd0387ed92ad83083e/packages/material-ui/src/ButtonBase/ButtonBase.js#L349
-component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
+component: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
I kinda wish React exported a componentPropType now...
@jedwards1211 a bit late to the party, but this might be helpful :) https://github.com/facebook/react/tree/v16.4.1/packages/react-is#determining-if-a-component-is-valid
@NMinhNguyen Thanks for the link. Yes, it's an opportunity to improve the component property type checking. Right now, it's almost like we have an any. However, some work needs to be done to convert the package into a proptype that will be pruned in production. Are you interested in this task? :)
@oliviertassinari
Are you interested in this task?
I am indeed :) Will try to prepare a PR in the next few days!