Skip to content

在 React.StrictMode 下无法使用  #201

@tint

Description

@tint

semi-ui version

  • 2.0.2

报错信息

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Typography which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node
at span
at Typography (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:914:566)
at Tooltip2 (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:969:710)
at LocaleConsumer (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1229:20)
at Base (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1236:1067)
at Text (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1237:10)
at span
at span
at span
at BreadcrumbItem (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1294:101)
at nav
at Breadcrumb (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1295:112)
at main
at Basic (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1552:847)
at Adapter (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1552:638)
at section
at Layout (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1552:1755)
at section
at Layout (http://localhost:4000/node_modules/.vite/@douyinfe_semi-ui.js?v=b1a1a510:1552:1755)
at App
overrideMethod @ VM709 react_devtools_backend.js:2540

Steps to reproduce 复现步骤

  • 收起侧边栏后再展开侧边栏

Reproducible code 复现代码

function App() {
  const { Header, Footer, Sider, Content } = Layout;
  return (
    <Layout>
      <Sider style={{ backgroundColor: "var(--semi-color-bg-1)" }}>
        <Nav
          defaultSelectedKeys={["Home"]}
          style={{ maxWidth: 220, height: "100%" }}
          items={[
            { itemKey: "Home", text: "首页", icon: <IconHome size="large" /> },
            {
              itemKey: "Histogram",
              text: "基础数据",
              icon: <IconHistogram size="large" />,
            },
            {
              itemKey: "Live",
              text: "测试功能",
              icon: <IconLive size="large" />,
            },
            {
              itemKey: "Setting",
              text: "设置",
              icon: <IconSetting size="large" />,
            },
          ]}
          header={{
            logo: (
              <img src="//lf1-cdn-tos.bytescm.com/obj/ttfe/ies/semi/webcast_logo.svg" />
            ),
            text: "直播运营后台",
          }}
          footer={{
            collapseButton: true,
          }}
        />
      </Sider>
      <Layout>
        <Header style={{ backgroundColor: "var(--semi-color-bg-1)" }}>
          <Nav
            mode="horizontal"
            footer={
              <>
                <Button
                  theme="borderless"
                  icon={<IconBell size="large" />}
                  style={{
                    color: "var(--semi-color-text-2)",
                    marginRight: "12px",
                  }}
                />
                <Button
                  theme="borderless"
                  icon={<IconHelpCircle size="large" />}
                  style={{
                    color: "var(--semi-color-text-2)",
                    marginRight: "12px",
                  }}
                />
                <Avatar color="orange" size="small">
                  YJ
                </Avatar>
              </>
            }
          ></Nav>
        </Header>
        <Content
          style={{
            padding: "24px",
            backgroundColor: "var(--semi-color-bg-0)",
          }}
        >
          <Breadcrumb
            style={{
              marginBottom: "24px",
            }}
            routes={[
              "首页",
              "当这个页面标题很长时需要省略",
              "上一页",
              "详情页",
            ]}
          />
          <div
            style={{
              borderRadius: "10px",
              border: "1px solid var(--semi-color-border)",
              height: "376px",
              padding: "32px",
            }}
          >
            <Skeleton
              placeholder={<Skeleton.Paragraph rows={2} />}
              loading={true}
            >
              <p>Hi, Bytedance dance dance.</p>
              <p>Hi, Bytedance dance dance.</p>
            </Skeleton>
          </div>
        </Content>
        <Footer
          style={{
            display: "flex",
            justifyContent: "space-between",
            padding: "20px",
            color: "var(--semi-color-text-2)",
            backgroundColor: "rgba(var(--semi-grey-0), 1)",
          }}
        >
          <span
            style={{
              display: "flex",
              alignItems: "center",
            }}
          >
            <IconBytedanceLogo size="large" style={{ marginRight: "8px" }} />
            <span>Copyright © 2019 ByteDance. All Rights Reserved. </span>
          </span>
          <span>
            <span style={{ marginRight: "24px" }}>平台客服</span>
            <span>反馈建议</span>
          </span>
        </Footer>
      </Layout>
    </Layout>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreact19React19 related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions