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

[button.Dropdown] 无法设置ref属性 #909

Closed
albyben opened this issue Oct 16, 2024 · 0 comments
Closed

[button.Dropdown] 无法设置ref属性 #909

albyben opened this issue Oct 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@albyben
Copy link
Collaborator

albyben commented Oct 16, 2024

重现链接或代码

import React from 'react'
import ReactDOM from 'react-dom'
import { Button } from '@kdcloudjs/kdesign'
const Demo = () => {
const hRef = React.useRef(null)
React.useEffect(() => {
  console.log(hRef, '====hRef')
})
  const demoButtonStyle = {
    margin: '0px 8px 8px 0'
  }
  const overlay1 = [
    {
      value: '1',
      label: '发布'
    },
    {
      value: '2',
      label: '生成凭证'
    },
    {
      value: '3',
      label: '打印'
    }
  ]
  const overlay2 = [
    {
      value: '1',
      label: '暂存'
    },
    {
      value: '2',
      label: '撤销'
    },
    {
      value: '3',
      label: '废弃'
    }
  ]
  return (
    <div>
      <Button.Dropdown overlay={overlay1} style={demoButtonStyle} onItemClick={() => console.log('onItemClick')} ref={hRef}>
        更多
      </Button.Dropdown>
      <Button.Dropdown style={demoButtonStyle} overlay={overlay2} type="similar" onClick={() => console.log('onClick')} onItemClick={() => console.log('onItemClick')}>
        提交
      </Button.Dropdown>
    </div>
  )
}
ReactDOM.render(<Demo />, mountNode)

重现问题步骤

将此代码贴到任一组件的演示代码中,打印出来ref为null

期望的结果是什么

实际的结果是什么

组件库版本号、浏览器信息

组件库与浏览器均为最新版本

@albyben albyben added the bug Something isn't working label Oct 29, 2024
kobehhh pushed a commit to kobehhh/kdesign that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants