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

[BUG] <Form.InputNumber> formatter 和 parser 会导致 React Maximum update depth exceeded #1672

Closed
1 task done
DaiQiangReal opened this issue Jun 21, 2023 · 1 comment · Fixed by #1767
Closed
1 task done

Comments

@DaiQiangReal
Copy link
Collaborator

Is there an existing issue for this?

  • I have searched the existing issues

Which Component

Form.InputNumber

Semi Version

No response

Current Behavior

Form 内 InputNumber 添加如示例代码所示 formatter 和 parser 后,输入值报错。

单独使用 InputNumber 没问题

Expected Behavior

No response

Steps To Reproduce

No response

ReproducibleCode

import React from 'react';
import { Form, Tooltip } from '@douyinfe/semi-ui';
import { IconHelpCircle } from '@douyinfe/semi-icons';

() => {
    const { Option } = Form.Select;

    return (
        <Form layout='horizontal' onValueChange={values=>console.log(values)}>
            <Form.Input field='UserName' label='用户名' style={{ width: 80 }}/>
            <Form.Input
                field='Password'
                label={{ 
                    text: '密码',
                    extra: <Tooltip content='详情'><IconHelpCircle style={{ color: 'var(--semi-color-text-2)' }}/></Tooltip> 
                }}
                style={{ width: 176 }}
            />
            <Form.InputNumber
            formatter={value => {
                return String(Number(`${value}`.replace(/\D/g, '')) / 60000);
            }}
            parser={value => {
                return String(Number(`${value}`.replace(/\D/g, '')) * 60000);
            }}
            min={60000}
            step={60000}
        />
            <Form.Select field="Role" label={{ text: '角色', optional: true }} style={{ width: 176 }}>
                <Option value="admin">管理员</Option>
                <Option value="user">普通用户</Option>
                <Option value="guest">访客</Option>
            </Form.Select>
        </Form>
    );
};


### Environment

```markdown
- OS:
- browser:

Anything else?

No response

@pointhalo
Copy link
Collaborator

v2.42.0-beta.0

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

Successfully merging a pull request may close this issue.

2 participants