Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Bug】React-VTable 使用图元报错:Uncaught TypeError: type is not a function #2041

Closed
mzhang-eric opened this issue Jul 4, 2024 · 2 comments · Fixed by #2046
Closed
Assignees

Comments

@mzhang-eric
Copy link

mzhang-eric commented Jul 4, 2024

版本:1.4.1

复现步骤:

  1. 使用如下官网示例:
    https://visactor.io/vtable/demo-react/usage/option-record

配置option如下:

const option = {
  columns: [
    {
      field: '0',
      title: 'name'
    },
    {
      field: '1',
      title: 'age',
      customLayout: () =>{
        const container = (
          <ReactVTable.Group
            attribute={{
              width: 80,
              height: 80,
              display: 'flex',
            }}
          >
            <ReactVTable.Text 
              attribute={{
                text: 'test',
                fontSize: 14,
                fontFamily: 'sans-serif',
                fill: 'rgb(51, 101, 238)',
              }}
            />
          </ReactVTable.Group>
        );
        return {
          rootContainer: container,
          renderDefault: false,
        };
      }
    },
    {
      field: '2',
      title: 'gender'
    },
    {
      field: '3',
      title: 'hobby'
    }
  ]
};
  1. 页面报错崩溃:Uncaught TypeError: type is not a function

image

【说明】
使用该示例主要是想实现一下 自定义单元格渲染,类似于 单元格自定义布局(JSX),区别在于我使用的是 react-vtable,想确认一下是当前版本是否支持这种使用方式?

因为我之前也尝试了语义化标签的用法,如示例 单元格自定义组件+dom组件,但是这种用法,看起来没有提供像上面 customLayout 函数中返回的 renderDefault。

因此,能否修复上述bug,或者提供这种使用方式?

@Rui-Sun
Copy link
Contributor

Rui-Sun commented Jul 4, 2024

非React环境的函数式写法,可以参考https://www.visactor.io/vtable/demo/custom-render/custom-cell-layouthttps://www.visactor.io/vtable/demo/custom-render/custom-cell-layout-jsx ,使用相关类或jsx标签,不能使用react-vtable提供的组件

@Rui-Sun
Copy link
Contributor

Rui-Sun commented Jul 4, 2024

renderDefault 会作为新需求补充到react-vtable中

@Rui-Sun Rui-Sun linked a pull request Jul 8, 2024 that will close this issue
21 tasks
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 a pull request may close this issue.

2 participants