Loading...
const Input = forwardRef(function Input(props, ref) {
return <input ref={ref} {...props} />;
});function Input({ ref, ...props }) {
return <input ref={ref} {...props} />;
}Function components get ref as a normal prop, so the forwardRef() wrapper is no longer needed.
forwardRef() out of habit.ref from props, without wrapping them in forwardRef().ref, e.g. ref?: React.Ref<HTMLInputElement>.It still works, but function components no longer need it, and React plans to deprecate it.
No. For class components, ref still points to the class instance and is not passed in props.