Closed LeoYuan closed 4 years ago
复现代码是怎么样的
随便引用一个自定义组件就能复现~
import Badge from 'mini-antui/es/badge';
<View>
<Badge><View slot="inner">Remax</View></Badge>
</View>
根因就是 axml 如 <form-0 ref={{item.props.__ref}} />
中的 item.props.__ref 出现了 undefined,就会出现这个 warning~
我试了下没有警告额
bug 描述
remax 对原生小程序组件会通过 React.forwardRef 进行一层封装,其中会通过 props.ref 往原生组件「传递」ref,在生成的 axml 中,也会通过类似 `<form-0 ref="{{item.props['ref']}}">` 获取 ref~
此时有个断言是,用户在使用小程序封装的组件时一定会传入 ref,但很可能没传,从而导致截图中的 warning,建议可以在用户没有传 ref 的时候,mock 一个实现,如:props.__ref = () => {}
复现步骤 使用任意一个自定义组件即可复现
期望结果 没有 warning
复现代码 😁
版本信息:
其他信息