You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to discuss how will we standardize the callbacks that some component take in order to behave in a controllable fashion. But since the signature of the callback function they accept is different across components, many new comers get confused.
Therefore, we have to come to a solution on this.
My proposal:
Every controllable component should only be controlled via value and onChange props. No more onRequestXxx.
the value must be as versatile as possible, if it make sense for it to be anything equatable with === then it should be marked as any.
The value should NOT be treated as falsy EVER! Implicit coercion leads to many many bugs.
The signature of the callback must follow this pattern: (e: Event, v: value, ...rest: any[]) => void
If access to the event is granted, there really shouldn't be any reason to provide a reason argument to indicate what triggered the change. The event can be checked against it's type or it's properties. I think this could be more accurate. (debatable 😁 )
Create a stateful StateWrapper components that can be used to make components stateful, useful for forms. It must implement: getValue(), setValue(value), clearValue(), defaultValue prop, onChange prop: (event, value, ...rest) => void
Clear state from all components that can be stateless. As much as possible.
3. Documentation and deployment:
Figure out a way to make usage less pain full, something like:
importSelectFieldfrom'material-ui/lib/SelectField';// For the actual component// As opposed to:importSelectFieldfrom'material-ui/lib/SelectField/stateful';// For the stateful version component
This is easy to implement, but I don't know if we want this, we should discuss this too.
We need to discuss how will we standardize the callbacks that some component take in order to behave in a controllable fashion. But since the signature of the callback function they accept is different across components, many new comers get confused.
Therefore, we have to come to a solution on this.
My proposal:
valueandonChangeprops. No moreonRequestXxx.valuemust be as versatile as possible, if it make sense for it to be anything equatable with===then it should be marked as any.falsyEVER! Implicit coercion leads to many many bugs.(e: Event, v: value, ...rest: any[]) => voidreasonargument to indicate what triggered the change. The event can be checked against it's type or it's properties. I think this could be more accurate. (debatable 😁 )@oliviertassinari @newoga @mbrookes Tell me what you guys think 😁
The Roadmap:
1. Standardize The Following Components:
DatePicker: onChange(event, date)DropDownMenu onChange(event, key, payload) => onChange(event, value, index), index?IconMenu (event, value)Drawer (deprecated prop) onChange(event, key, payload) => onChange(event, state)RadioButtonGroup onChange(event, newSelection)SelectField, DropDownMenu onChange(event, index, value) => onChange(event, value, index)Slider onChange(event, value)Tabs onChange(value) => onChange(event, value)[Tabs][BottomNavigation] Use value over index property #7741TextField onChange(event) => onChange(event, value)[TextField] Standardize onChange callback and remove valueLink #3699TimePicker onChange(null, time) => onChange(event, time)Table([Table] Send event object after click, hover, hoverOut on cell. #3002)2. Purge State:
StateWrappercomponents that can be used to make components stateful, useful for forms. It must implement:getValue(),setValue(value),clearValue(),defaultValue prop,onChange prop: (event, value, ...rest) => void3. Documentation and deployment:
This is easy to implement, but I don't know if we want this, we should discuss this too.