-
Notifications
You must be signed in to change notification settings - Fork 52
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
Accept props that are empty (For Redux mapStateToProps) #121
Conversation
👋 @TriPSs thank you for putting this together! |
Thanks for the PR. As mentioned in #119 - I'm still not sure if just by doing |
Yes that is indeed for empty arrays and correct me if i'm wrong this also works if its an empty string. And is !props[name] not almost the same as hasOwnProperty? |
@TriPSs empty strings are already false in javascript. "" == false && '' == false // true Alright, I've looked at the code more closely and #119. I've checked the cases of if (!nextState.resolved.hasOwnProperty(name)) { @ericclemmons What do you think? /cc @ericclemmons, @TriPSs, @peterpme, @salmanm |
Let me know and i can update the pr |
@monder I just toughed, if you remove it completely and the prop is already filled, then it will overwrite it, right? I don't think thats what you want. |
Thank you both for checking in on the issue! I'd just like to point out that there's a fundamental difference in Javascript (and React) between
|
@TriPSs
For example: const someObj = {
foo: 1,
bar: null,
baz: undefined,
}
`someObj.hasOwnProperty(foo) === true`
`someObj.hasOwnProperty(bar) === true`
`someObj.hasOwnProperty(baz) === true`
`!someObj.foo === false`
`!someObj.baz === true`
`!someObj.bar === true` |
To me resolver facilitates an excellent way to "get async stuff loaded Am I making any sense here? On Nov 22, 2016 22:42, "Peter Piekarczyk" notifications@github.com wrote:
|
@TriPSs why wouldn't you want to overwrite it then? |
@salmanm I agree, I think that's the issue we're trying to solve and this @monder it's time I ask - (still getting comfortable with the lib) - are we talking about local props being overwritten by what's coming in from an async request, or making sure we're not making the same request on the client if it's been fulfilled successfully on the server? |
Yep... What I propose is that we should not ignore any props... If the developer has written it, he's responsible. :P |
@TriPSs what do you think? Is that OK? If we remove that last part and roll with the punches? Thank you for helping out with this by the way, you've made my life a little easier :) |
@TriPSs yessir! Does that work for you? |
@peterpme Yes! Updated the pull request! |
@peterpme sure, I like it... |
Published v3.1.0 on npm. Thank you all. |
This way it does not conflict with mapStateToProps when the prop is still empty.