blueberryapps / onion-form

React Redux form builder with great UX validations
49 stars 2 forks source link

Allow to pass value from top #2

Open alcedoatthis opened 7 years ago

alcedoatthis commented 7 years ago

Useful e.g. for check/uncheck all checkbox. Value can be combined from other values and passed directly to check-all checkbox. IMHO it is better to move {...rest} props below others, but I'm not sure if this behaviour is wanted (?)

ondrejbartas commented 7 years ago

@alcedoatthis this does not make any sense, without value from connected state you don't need onion form at all..

alcedoatthis commented 7 years ago

@ondrejbartas Current api is kept, if You don't pass value as a prop to component. Is there any example of functionality mentioned? IMHO other options like hooking setFieldValue into componentWillReceiveProps seems to be hacky. What about optional argument to connectField? mergeProps(stateProps, dispatchProps, ownProps): props passed to connect. Something like:

export default function connectField(fieldName, ..., mergeProps) {
  return FieldComponent => {
    @connect(
      (state, { onionFormName }) => ({...}),
      (dispatch, { onionFormName }) => ({...}),
      mergeProps
    ) // ...