mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(react): setting a ref should allow other props to be passed in, closes #22609
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user