Skip to content

Commit

Permalink
fix: fix react-vtable build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jun 18, 2024
1 parent 41b4de6 commit 9d9a363
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import ReactDOM from 'react-dom/client';
import type { CustomLayoutFunctionArg } from '../../../src';
import { ListTable, ListColumn, CustomLayout, Group, Text, Tag, Image } from '../../../src';
import {
Expand Down Expand Up @@ -168,6 +169,7 @@ function App() {
// eslint-disable-next-line no-undef
// (window as any).tableInstance = table;
}}
ReactDOM={ReactDOM}
>
<ListColumn field={'id'} title={'ID'} />
<ListColumn field={'name'} title={'Comment'} width={300}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable max-len */
import { useEffect, useRef, useState } from 'react';
import ReactDOM from 'react-dom/client';
import type { CustomLayoutFunctionArg } from '../../../src';
import { ListTable, ListColumn, CustomLayout, Group, Text, Tag, Image } from '../../../src';
import { Avatar, Button, Card, Popover, Space, Typography } from '@arco-design/web-react';
Expand Down Expand Up @@ -210,6 +211,7 @@ function App() {
// eslint-disable-next-line no-undef
// (window as any).tableInstance = table;
}}
ReactDOM={ReactDOM}
>
<ListColumn field={'bloggerId'} title={'ID'} />
<ListColumn field={'bloggerName'} title={'Name'} width={220}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import ReactDOM from 'react-dom/client';
import type { CustomLayoutFunctionArg } from '../../../src';
import { ListTable, ListColumn, CustomLayout, Group, Text, Tag, Image } from '../../../src';
import { Avatar, Button, Card, Popover, Space, Typography } from '@arco-design/web-react';
Expand Down Expand Up @@ -296,6 +297,7 @@ function App() {
// eslint-disable-next-line no-undef
(window as any).tableInstance = table;
}}
ReactDOM={ReactDOM}
>
<ListColumn field={'0'} title={'name'} />
<ListColumn field={'1'} title={'age'} />
Expand Down
4 changes: 1 addition & 3 deletions packages/react-vtable/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as VTable from '@visactor/vtable';

export * from './tables';
export * from './components';
export { VTable };
export * from './vtable';

export const version = __VERSION__;
10 changes: 6 additions & 4 deletions packages/react-vtable/src/tables/base-table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/display-name */
import * as VTable from '@visactor/vtable';
// import * as VTable from '@visactor/vtable';
import { VTable } from '../vtable';
import React, { useState, useEffect, useRef, useImperativeHandle, useCallback } from 'react';
import ReactDOM from 'react-dom/client';
import type { ContainerProps } from '../containers/withContainer';
import withContainer from '../containers/withContainer';
import type { TableContextType } from '../context/table';
Expand Down Expand Up @@ -46,6 +46,8 @@ export interface BaseTableProps extends EventsProps {
height?: number;
skipFunctionDiff?: boolean;

ReactDOM?: any;

/** 表格渲染完成事件 */
onReady?: (instance: IVTable, isInitial: boolean) => void;
/** throw error when chart run into an error */
Expand Down Expand Up @@ -159,9 +161,9 @@ const BaseTable: React.FC<Props> = React.forwardRef((props, ref) => {
vtable = new VTable.ListTable(props.container, parseOption(props));
}
// vtable.scenegraph.stage.enableReactAttribute(ReactDOM);
vtable.scenegraph.stage.reactAttribute = ReactDOM;
vtable.scenegraph.stage.reactAttribute = props.ReactDOM;
vtable.scenegraph.stage.pluginService.register(new VTableReactAttributePlugin());
vtable.scenegraph.stage.params.ReactDOM = ReactDOM;
vtable.scenegraph.stage.params.ReactDOM = props.ReactDOM;
tableContext.current = { ...tableContext.current, table: vtable };
isUnmount.current = false;
},
Expand Down
3 changes: 3 additions & 0 deletions packages/react-vtable/src/vtable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as VTable from '@visactor/vtable';

export { VTable };

0 comments on commit 9d9a363

Please sign in to comment.