AxaFrance / react-toolkit

Flexible components html + css + react using BEM convention. Maybe, you can call it "Design System" !
https://axafrance.github.io/design-system/
MIT License
97 stars 63 forks source link

Form component - Always value instead of values / value #665

Open johnmeunier opened 4 years ago

johnmeunier commented 4 years ago

A form component have to take a value. This value is passed to the component by a prop. This prop can be called value or values, depending on wether the value is an array or a primitive.

For example :

<Component value="text" />
Or
<Component values={["text1, text2"]} />

I don't have any example where this difference was useful. Instead, I've got several examples where this was really disturbing. For example, when you code a form generator, you have to deal with the value type to return a component with value or with values ...

Have you example when this design choice was a good thing in your project ?

Can we drop out this and always use value ?

Of course, the change can be smooth, without breaking change (add the support of value in every component and deprecate after few versions the values prop).

What is your opinion about that ?

arnaudforaison commented 3 years ago

En complément, l'attribut value pour un input en Typescript c'est string | number | readonly string[] donc celui-ci prend donc aussi un tableau. Je dirais qu'il faut se baser sur les standards HTML