Answer the question
In order to leave comments, you need to log in
How to use forwardRef on class bean?
Good afternoon, I need a ref on a child component that is at the 2nd nesting level, I use forwardRef.
Parent of the component to be referenced:
interface BProps {
title: string;
innerRef?: React.Ref<CComponent>;
}
class BComponent extends React.Component<BProps> {
render() {
const {innerRef, ...props} = this.props;
return <CComponent {...props} ref={innerRef} />;
}
}
export default React.forwardRef<CComponent, BProps>((props, ref) => (
<BComponent
{...props}
innerRef={ref}
/>
));
props.children
writes that chilren is not expected in component props. BProps
children?: React.ReactNode
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question