fix(react): setting a ref should allow other props to be passed in, closes #22609

This commit is contained in:
Ely Lucas
2020-12-08 13:45:24 -07:00
committed by GitHub
parent 61cf0c534e
commit 31f45cdcc9
5 changed files with 81 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import {
} from './utils';
interface IonicReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
forwardedRef?: React.Ref<ElementType>;
forwardedRef?: React.RefObject<ElementType>;
href?: string;
routerLink?: string;
ref?: React.Ref<any>;
@ -46,7 +46,7 @@ export const createReactComponent = <PropType, ElementType>(
componentDidUpdate(prevProps: IonicReactInternalProps<PropType>) {
// Try to use the forwarded ref to get the child node.
// Otherwise, use the one we created.
const node = (this.props.forwardedRef || this.ref.current!) as HTMLElement;
const node = (this.props.forwardedRef?.current || this.ref.current!) as HTMLElement;
attachProps(node, this.props, prevProps);
}