# 警告：forwardRef 渲染函数只接受两个参数：props 和 ref。您是否打算传递一个 ref？

- **ID:** `react/forwardref-children-prop-warning`
- **领域:** react
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

使用 React.forwardRef 包装的组件在其渲染函数中接收了超过两个参数（例如 props、ref 和额外的第三个参数如 children），这违反了 forwardRef 的签名。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| react@18.2.0 | active | — | — |
| react@17.0.2 | active | — | — |

## 解决方案

1. ```
   Change the forwardRef render function to accept exactly two parameters: props and ref. Access children via props.children.
   ```
2. ```
   If using TypeScript, ensure the forwardRef type signature matches: React.forwardRef<RefType, PropsType>((props, ref) => ...)
   ```

## 无效尝试

- **Adding a third parameter to the forwardRef render function to accept children explicitly** — React.forwardRef only provides two arguments; any extra parameter will be undefined and the warning persists. (95% 失败率)
- **Wrapping the component in another HOC that passes children as a separate prop** — The underlying forwardRef still receives the extra argument; the warning is about the render function signature, not prop structure. (80% 失败率)
- **Ignoring the warning as it doesn't break the app immediately** — The warning indicates potential ref forwarding issues that can cause bugs with focus management or third-party libraries. (70% 失败率)
