中等React
0 1

使用displayName?

【概念释义】

displayName 是组件的可读调试名称,显示在 React DevTools警告栈HOC 包裹后识别原组件。对匿名函数、memo、forwardRef 包裹的组件尤其重要,便于定位问题。

【基础使用】

jsx
const Input = forwardRef(function TextInput(props, ref) {
  return <input ref={ref} {...props} />;
});
Input.displayName = "TextInput";

登录查看完整 1147

回答讨论

暂无讨论,登录后可抢先发言

本题库更多题目(50)