
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
date-year-picker
Advanced tools
年代选择器
import DateYearPicker from 'date-year-picker';
使用日期选择器的时候,突然发现年选择器比较少, 工作中恰好有这样的需求,所以就使用原生封装了一个
<DateYearPicker
createElement={React.createElement}
placeholder="请选择所属财年"
/>
react 通过jsx创建自定义组件并导出html模版,为了借用它这种工作模式,
需要把React.createElement方法传入进来 否则返回空内容
⚠️ 注意
如果在react表单验证中使用,控制台有可能会抛出以下异常:
“Function components cannot be given refs.
Attempts to access this ref will fail.”
原因是不能为函数组件提供引用,虽然不影响使用,
但是看起来让人很不舒服
这时候你需要将它转化一下,如下:
class SetDateYearPicker extends React.Component {
render() {
return <DateYearPicker {...this.props} />
}
}
然后在getFieldDecorator下便可正常使用
<SetDateYearPicker
createElement={React.createElement}
placeholder="请选择所属财年"
/>
react 同时适用下面这种方法
<date-year-picker
placeholder="请选择所属财年"
>
</date-year-picker>
在引人组件的时候同时创建了自定义元素 date-year-picker 直接在html传入对应属性即可
有什么好的想法,欢迎一起成长交流 WeChat:mrliaojun
FAQs
We found that date-year-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.