Open bombillazo opened 3 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
input-number | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 9, 2024 1:55pm |
@afc163 @zombieJ Any feedback on this PR?
@afc163 @zombieJ Hello there, any feedback?
此次更改对 InputNumber.tsx
文件进行了增强,主要涉及 InputNumberProps
接口和 InternalInputNumber
组件的内部逻辑。parser
和 formatter
函数被修改为接受一个额外的参数 prevValue
,以便访问输入的先前值。此外,引入了新的 validator
函数,用于在处理输入字符串之前进行验证。组件的内部状态管理也进行了更新,使用 useRef
钩子跟踪当前和先前的输入值。
文件 | 更改摘要 |
---|---|
src/InputNumber.tsx | 修改 InputNumberProps 接口中的 parser 和 formatter 函数,添加 prevValue 参数;新增 validator 函数。 |
InputNumber
组件的修改,特别是引入了泛型类型参数,与主 PR 中对 InputNumberProps
接口的增强相关。🐰 在数字的世界里跳跃,
输入的变化如风般轻巧。
旧值新值相互交织,
验证与格式,完美结合。
兔子欢呼,乐在其中,
让每个输入,皆成美梦! 🌟
[!TIP]
New features
Walkthrough comment now includes: - Possibly related PRs: A list of potentially related PRs to help you recall past context. - Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file. Notes: - Please share any feedback in the [discussion post](https://discordapp.com/channels/1134356397673414807/1282535539299323995) on our Discord. - Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
This PR enhances the component by adding a new callback:
Validator
, which prevents the input from changing if the value does not pass the validation. This is useful to prevent users from inputting unwanted characters in the input.The Parser callback has also been enhanced with a new
info
second param that returns the previous value. This is useful for formatting or validation purposes when one is modifying the value and needs to compare the old and new values.Summary by CodeRabbit