Coder Social home page Coder Social logo

Comments (7)

NWYLZW avatar NWYLZW commented on June 14, 2024 1

如果label强制要求是string类型的,使用数字类型应该报warning进行提示 这里的数字类型1是可以显示的,数字类型为0显示不了,是一个非常明显的问题 真正能暴露使用问题的方式是进行warning提示,而不是使用者使用同一类型的数据的时候显示出与其他数据不同的行为 这很容易导致难以预料的业务问题

首先数字的输入是 ub(unspecified behavior),其次如果你使用的是现代化的编辑起在类型上便会对类型进行检查,并不会遗留问题到生产环境再被发现。

如果你确实觉得组件库需要来对这些 ub 做防御型编程可以提出一个 feature request,关于如何对于 falsy(undefined,null,0,false) 的各种特殊情况下对于数据输入的转化逻辑,这可以被讨论应该如何防御,而且这对于整个系统来说都是有益的。

from tdesign-react.

github-actions avatar github-actions commented on June 14, 2024

👋 @suedar,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

from tdesign-react.

HaixingOoO avatar HaixingOoO commented on June 14, 2024

image
label使用string

from tdesign-react.

suedar avatar suedar commented on June 14, 2024

不能这样单纯的处理,有的options是依赖后端返回的,这样很容易出现业务问题,至少应该兼容一下。。。

from tdesign-react.

NWYLZW avatar NWYLZW commented on June 14, 2024
options={options.map(i => ({ label: i.label || '无', ...i }))}

from tdesign-react.

NWYLZW avatar NWYLZW commented on June 14, 2024

不能假定在使用的用户需要的就是什么,可能是需要隐藏,可能是需要展示文案(文案也是不确定的),万一有的依赖就是不展示呢(可能性比较小)
基于以上的观点,如果我兼容了,问题就不会暴露出来,可能作为一种默认行为被继续使用
其次如果你需要对于 falsy 的特殊兼容支持,这可能是一个比较大的需求,对于单一职责的原子组件来说引入过多复杂度对于组件的维护并不是一件好事
最后由业务向后端要求数据格式的准确性,也是后端应该做到的
所以说约定了 string 的情况下,对于 only string 的支持也是一种合理的措施

from tdesign-react.

suedar avatar suedar commented on June 14, 2024

如果label强制要求是string类型的,使用数字类型应该报warning进行提示
这里的数字类型1是可以显示的,数字类型为0显示不了,是一个非常明显的问题
真正能暴露使用问题的方式是进行warning提示,而不是使用者使用同一类型的数据的时候显示出与其他数据不同的行为
这很容易导致难以预料的业务问题

from tdesign-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.