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

Cannot override TabPane when wrapping #32439

Closed
1 task done
mellis481 opened this issue Oct 11, 2021 · 2 comments
Closed
1 task done

Cannot override TabPane when wrapping #32439

mellis481 opened this issue Oct 11, 2021 · 2 comments

Comments

@mellis481
Copy link
Contributor

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Wrap TabPane in a custom exponent and try to extend the tab property. Here is an example:

const CustomTabPane = (props) => {
  const { hasError, tab, children, ...rest } = props;
  const tabTitle = (
    <>
      {tab}
      {hasError ? "****" : ""}
    </>
  );
  return (
    <TabPane {...rest} tab={tabTitle}>
      {children}
      {hasError && " (Has Error)"}
    </TabPane>
  );
};

const Demo = () => (
  <Tabs defaultActiveKey="1" onChange={callback}>
    <CustomTabPane tab="Tab 1" key="1">
      Content of Tab Pane 1
    </CustomTabPane>
    <CustomTabPane tab="Tab 2" key="2" hasError>
      Content of Tab Pane 2
    </CustomTabPane>
    <CustomTabPane tab="Tab 3" key="3">
      Content of Tab Pane 3
    </CustomTabPane>
  </Tabs>
);

I would expect the title for the second tab pane to be "Tab 2****", but it is just "Tab 2". I cannot extend the value.

What is expected?

Extended tab value will appear.

What is actually happening?

The original tab value appears

Environment Info
antd 4.16.13
React react
System Windows
Browser Chrome
@xrkffgg
Copy link
Member

xrkffgg commented Oct 12, 2021

see https://codesandbox.io/s/basic-antd-4-17-0-alpha-5-forked-h0z66

CustomTabPane props is not what you think

@afc163
Copy link
Member

afc163 commented Oct 12, 2021

Duplicate of #4853

@afc163 afc163 marked this as a duplicate of #4853 Oct 12, 2021
@afc163 afc163 closed this as completed Oct 12, 2021
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

3 participants