fix(Button): fix button prop inference when using as prop#131
fix(Button): fix button prop inference when using as prop#131
Conversation
d2ded2b to
afae825
Compare
| return <Component {...props} {...buttonProps} ref={ref} />; | ||
| }, | ||
| ); | ||
| const Button: DynamicRefForwardingComponent<'button', ButtonProps> = |
There was a problem hiding this comment.
IIRC the reason we didn't do this was to keep the type simple since button is used everywhere and the as types break or are complex in weird ways
There was a problem hiding this comment.
It "seems" ok from cursory testing, but could be overlooking a more complex case. I can look into an alternative way to typing when I get some spare time.
There was a problem hiding this comment.
I think the question was more why does button need to allow any as since things should be using it as the base not the other way around
There was a problem hiding this comment.
This change actually doesn't loosen the as prop to allow any component. It's still restricted to HTML elements.
The original type remains intact here:
Line 117 in afae825
Fix was intended to address this issue (sorry forgot to link when I created):
react-bootstrap/react-bootstrap#6941
Fixes type inference on custom element props such as event handlers. Previously it was all defaulting to button elements and ignoring
asFixes an issue found in RB: react-bootstrap/react-bootstrap#6941