oreqizer / redux-forms

ARCHIVED! :page_facing_up: A simple form manager for Redux.
https://oreqizer.gitbooks.io/redux-forms/content/
MIT License
15 stars 1 forks source link

redux-forms and react-redux-forms use different versions of ramda making me bundle it twice #21

Closed rileylnapier closed 7 years ago

rileylnapier commented 7 years ago

im seeing rambda in my entry bundle under redux-forms and in my vendor bundle from min-chunks > 2 (redux-forms-react). you're library is the only one using ramda in my package. if i update redux-forms to use ramda "0.24.1" then i don't get this issue.

i created this https://github.com/oreqizer/redux-forms/compare/master...rileylnapier:patch-1

image

image

oreqizer commented 7 years ago

Thanks for the report, will take a look

oreqizer commented 7 years ago

Updated the deps, please check if everything is OK for you

rileylnapier commented 7 years ago

👍 looks good. thanks for quick turnaround

rileylnapier commented 7 years ago

i seem to be getting an error and im not sure if its related to upgrading ramda.

when i destroy a form. i get "REMOVE_FORM" and "SUBMIT_STOP" events. I notice after this, there remains a field on the form called "submitting".

image

when I use the selectors from redux-forms, we use the following code:

function errorSelector(name, state) {
    var form = (0, _path2.default)(['reduxForms', name], state);
    console.log(name, form);
    if (!form) {
        return EMPTY;
    }

    return memError(form.fields);
}

the check on !form doesn't seem to be good enough as my form === { submitting: false }.

if I change the code

function errorSelector(name, state) {
    var form = (0, _path2.default)(['reduxForms', name], state);
    console.log(name, form);
    if (!form || !form.fields) {
        return EMPTY;
    }

    return memError(form.fields);
}

by adding !form.fields ~ then it doesn't error out, but this doesn't seem like a good patch.

it happens with both errorSelector and isValid. unclear if any other selectors are affected. I also found this issue: https://github.com/ramda/ramda/issues/2219

oreqizer commented 7 years ago

that's weird, never run into that. I will check it out, thanks for reporting

oreqizer commented 7 years ago

does SUBMIT_STOP get fired automatically, or do you return a Promise in the onSubmit callback which causes a delayed action trigger? this behavior would make sense in that case. it is an edge case I haven't thought of, I will have to adjust stuff to cover such cases

rileylnapier commented 7 years ago

it doesn't return a promise, it doesn't return anything... its tied directly to a thunk action and uses redux-promise-middleware.

looks something like this:

export const loginUser = ({
  email,
  password,
  timeout = DEFAULT_TIMEOUT
}) => (dispatch) => {
  dispatch({
    type: LOGIN_USER,
    payload:
      api_loginEmail({
        email,
        password
      })
  })
}
rileylnapier commented 7 years ago

i wrote a temporary fix formyself

import {
  errorSelector,
  isValid
} from "redux-forms/selectors";

export const formErrorSelector = (formName, { reduxForms }) => {
  const thisForm = reduxForms[formName];
  if (!thisForm || !thisForm.fields) {
    return {};
  }

  return errorSelector(formName, { reduxForms });
}

export const formIsValid = (formName, { reduxForms }) => {
  const thisForm = reduxForms[formName];
  if (!thisForm || !thisForm.fields) {
    return {};
  }

  return isValid(formName, { reduxForms });
}
oreqizer commented 7 years ago

@rileylnapier I updated redux-forms-react to v0.12.0. It uses redux-forms v1.0.0-1 (pre-release). It contains a fix for this issue.

Note that these selectors were renamed:

I recommend you to update redux-forms-react to v1.0.0-2 in the near future, as it will be the stable and supported version soon. However, I am going to keep releasing patches for v0.12 for some time if people demand so. 👍

Let me know if your issue persists!

rileylnapier commented 7 years ago

sigh.... after upgrading, and going through upgrade guide... im finding bugs :(

trying to create a field like this image

turns into props like this image

which i guess its stripping off the props i need to render a checkbox. really any props passed to a component that is decorated by @field seems to get stripped. including placeholder

oreqizer commented 7 years ago

I see, thanks for the report, I will fix this right away

rileylnapier commented 7 years ago

on positive note... im not seeing the original error!!!

oreqizer commented 7 years ago

Ok redux-forms-react 1.0.0-5 should be fixed. Thanks for the reports!

I added regression tests to cover these cases.

rileylnapier commented 7 years ago

looks good! thanks for quick turnaround. if i see anything else, ill create new issue