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

columnNodes 返回的子节点能否自定义? #256

Open
lqPrototype opened this issue Mar 10, 2022 · 0 comments
Open

columnNodes 返回的子节点能否自定义? #256

lqPrototype opened this issue Mar 10, 2022 · 0 comments

Comments

@lqPrototype
Copy link

lqPrototype commented Mar 10, 2022

  1. 因为这样容易让开发者自定义
  2. 扩展性更强
 const mergedOptionColumns = isEmpty ? [{ options: emptyList }] : optionColumns;

const columnNodes: React.ReactElement[] = mergedOptionColumns.map(
    (col, index) => {
        const prevValuePath = activeValueCells.slice(0, index);
        const activeValue = activeValueCells[index];
        // return item
        const custormRenderColumnItem = this.props?.custormRenderColumnItem;
        const isCustormRenderItem =
            custormRenderColumnItem &&
            typeof custormRenderColumnItem === "function";
        if (isCustormRenderItem) {
            const CustormRenderColumnItem = custormRenderColumnItem();
            return (
                <CustormRenderColumnItem
                    key={index}
                    {...columnProps}
                    prefixCls={mergedPrefixCls}
                    options={col.options}
                    prevValuePath={prevValuePath}
                    activeValue={activeValue}
                />
            );
        }

        return (
            <Column
                key={index}
                {...columnProps}
                prefixCls={mergedPrefixCls}
                options={col.options}
                prevValuePath={prevValuePath}
                activeValue={activeValue}
            />
        );
    }
);

// >>>>> Render
return (
    <div
        className={classNames(`${mergedPrefixCls}-menus`, {
            [`${mergedPrefixCls}-menu-empty`]: isEmpty,
            [`${mergedPrefixCls}-rtl`]: rtl,
        })}
        ref={containerRef}
    >
        {columnNodes}
    </div>
);
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

No branches or pull requests

1 participant