Skip to content

Conversation

@shentao1
Copy link

当前BUG:遇到如下写法任然会被加上data-v-id,而React.Fragment是不能被加额外熟悉,不然会报如下错误:Warning: Invalid prop data-v-d75c71aa supplied to React.Fragment. React.Fragment can only have key and children props.

解决方案:添加 ignoreNode 插件属性,传入函数,可自定义无需处理的节点,返回true则表示无需处理。然后在如下代码加入此逻辑,完全向下兼容。如需处理完整React.Fragment,参考README文档 ignoreNode 属性
image

@shentao1
Copy link
Author

shentao1 commented Nov 13, 2023

补充下引起错误的写法如下:

// index.tsx
import React from 'react';
const Fragment = React.Fragment;
export default ()=>{
return (<Fragment>
<div></div>
</Fragment >);
};

@gaoxiaoliangz
Copy link
Owner

这个逻辑最好设计成对用户无感,添加配置不一定是最优解。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants