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

【2.0】DatePicker 自定义 children API 变更 #1036

Closed
xoptimal opened this issue Mar 22, 2017 · 11 comments
Closed

【2.0】DatePicker 自定义 children API 变更 #1036

xoptimal opened this issue Mar 22, 2017 · 11 comments
Assignees
Milestone

Comments

@xoptimal
Copy link

Environment(required) | 环境(必填)

1.0.3 / browser / google chrome 56.0.2924.87

What did you do? Please provide steps to re-produce your problem.(请提供复现步骤)

improt DatePicker

code:

        <DatePicker
          mode="date"
          title="选择日期"
          value={zhNow}
          {...getFieldProps('date1', {
            initialValue: zhNow,
            onChange(e){
              dispatch({
                type   : 'UserModel/save',
                payload: {
                  birthday: moment(e).format('YYYY-MM-DD')
                }
              });
            }
          })}
          minDate={minDate}
          maxDate={maxDate}
        >
          <div className={styles.item}>
            <span>出生日期</span>
            <div className={styles.value}>
              <span>{props.birthday}</span>
            </div>
            <div className={styles.icon_next}/>
          </div>
        </DatePicker>

What happen?(发生了何种非正常现象)

console output :

Warning: Unknown prop `extra` on <div> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop

What do you expected?(预期的正常效果)

console no warning hint

@paranoidjk
Copy link
Contributor

先请试下 1.0.6 最新是不是已修复,谢谢

@paranoidjk
Copy link
Contributor

我这边没有 1.0.6 复现,请提供可复现的demo

@warmhug
Copy link
Contributor

warmhug commented Mar 22, 2017

这是正常现象,仔细看 extra api 说明 以及示例

@paranoidjk
Copy link
Contributor

paranoidjk commented Mar 22, 2017

@warmhug
https://github.com/ant-design/ant-design-mobile/blob/master/components/date-picker/index.web.tsx#L67
这个命名值得多考虑,叫 extra 只是为了搭配 ListItem 使用的场景,设计之初选一个合法的 html 属性名可能好一点

另外,类似的场景,感觉 rc-slider handle 这样子的api设计好一点,不依赖component嵌套,潜规则的props传递,而是显式的告诉用户 https://github.com/react-component/slider/blob/master/examples/handle.js#L34

@paranoidjk
Copy link
Contributor

我的想法是下个大版本改下API:

const customHandle = ({value, onClick}) => {
   return <List.Item arrow="horizontal" extra={value} onClick={onClick}>日期(CST)</List.Item>
}

const Demo = () => (
  <DatePicker
    mode="date"
    title="选择日期"
    extra="可选,小于结束日期"
    minDate={minDate}
    maxDate={maxDate}
    handle={customHandle}
  >
  </DatePicker>
)

@warmhug 这样如何?

@warmhug
Copy link
Contributor

warmhug commented Mar 22, 2017

可以的,可以再讨论讨论、这个感觉不用着急。

另外记得,semver 版本号 1.x 版本要兼容升级,2.x 版本才能有 break change 的

@paranoidjk paranoidjk self-assigned this Mar 22, 2017
@paranoidjk paranoidjk added this to the 2.0 milestone Mar 22, 2017
@paranoidjk paranoidjk changed the title DatePicker 使用相关疑问 【1.2.0】DatePicker 自定义 children API 变更 Mar 22, 2017
@paranoidjk paranoidjk changed the title 【1.2.0】DatePicker 自定义 children API 变更 【2.0】DatePicker 自定义 children API 变更 Mar 22, 2017
@warmhug warmhug mentioned this issue May 11, 2017
33 tasks
@paranoidjk paranoidjk assigned warmhug and unassigned paranoidjk Aug 28, 2017
@warmhug
Copy link
Contributor

warmhug commented Sep 5, 2017

@paranoidjk 再次评估下改动的成本收益、这几天确定结论

@paranoidjk
Copy link
Contributor

目前这种api 其实对 children 接收的 props 是有潜规则要求的,很容易就会有用户在自定义 children 这块出问题。

ref: #1801 ant-design/ant-design#5165

cc @silentcloud @afc163 @benjycui 发表下意见

@paranoidjk
Copy link
Contributor

先不改 api,完善文档。

lixiaoyang1992 pushed a commit to lixiaoyang1992/ant-design-mobile that referenced this issue Apr 26, 2018
@shopshow
Copy link

shopshow commented May 8, 2018

能不能支持 datepicker 弹出时增加callback?以便处理某些触发事件

@warmhug
Copy link
Contributor

warmhug commented May 9, 2018

@shopshow support onVisibleChange

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

4 participants