Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined state on prop change #46

Merged
merged 3 commits into from
Jul 14, 2016
Merged

Fix undefined state on prop change #46

merged 3 commits into from
Jul 14, 2016

Conversation

marcneuwirth
Copy link
Member

Because timesAHundredMinusState never actually used state, it was unnoticed that state would be undefined when the deref was called from componentWillReceiveProps. This change should pass the current state through at the time of componentWillReceiveProps and update the tests to reflect that case.

It looks like the Change log wasnt updated for v1, so I also didn't add anything for this fix. If there is anything else that I missed, let me know.

/cc @colbyr

): Object {
return oFilterMap(
dependencies,
(dep) => dep.deref && dep.deref.length > 0,
(dep) => calculate(dep, props)
(dep) => calculate(dep, props, state)
Copy link
Contributor

@colbyr colbyr Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm so I think the only thing I would change is that, if the the deref doesn't declare a state argument (i.e. the argument at index 1) it shouldn't receive it.

return oFilterMap(
  ...,
  (dep) => {
    if (dep.deref.length === 1) {
      return caluclate(dep, props);
    }
    return calculate(dep, props, state);
  }
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcneuwirth sorry I was thinking too hard... caclulate does the arity check, it was good the way you had it. Changed it back 8906900.

@colbyr
Copy link
Contributor

colbyr commented Jul 13, 2016

@marcneuwirth one comment, otherwise looks good. Once that's fixed I'll merge and publish. Thanks 🌴

@marcneuwirth
Copy link
Member Author

Updated, thanks @colbyr

@colbyr colbyr merged commit 96a3c56 into master Jul 14, 2016
@colbyr colbyr deleted the state-fix branch July 14, 2016 12:57
@colbyr
Copy link
Contributor

colbyr commented Jul 14, 2016

@marcneuwirth published as version 1.2.2

@marcneuwirth
Copy link
Member Author

👍 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants