Conversation
Codecov Report
@@ Coverage Diff @@
## master #366 +/- ##
=========================================
+ Coverage 92.98% 93.09% +0.1%
=========================================
Files 51 52 +1
Lines 328 333 +5
=========================================
+ Hits 305 310 +5
Misses 23 23
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me.
@wuct I'm not seeing the same prettier error locally. any ideas?
|
876d455
to
0c2a402
Compare
okay this should do it. prettier just was updated between PR |
About prettier - you need to rebase to see an errors. Wanna add what I think about. withProps(({ blabla }) => ({...blabla})); Yes it somehow longer, but not a lot. Having that js world is moving into direction of typed languages we see that type of It's just IMO but all methods except |
/shrug I agree, not a big fan of strings in general for the same reason. I'll leave this open and let you guys decide, not a blocker for me of course. |
Also I assume you mean just passing the object. Or is spreading into an empty object somehow better for type inference?
|
Your solution is better for one prop |
OK well for the sake of argument.. if strings are still 'good enough' not to be deprecated, perhaps a touch of lodash style pathing would make this even more useful?
|
Since destructing still kind of sucks in the crashing null errors, something that |
Could even pass a default like
|
IMO Undefined errors are now solved with flowtype, typescript so not a problem, yes syntax still sometimes looks ugly like |
types don't help you with runtime api response though, like relay data. you either have to write tons of defaults like ^ that's a bad example, but you know what i mean. responses can be null when you're trying to access nested args |
In any case.. I'm playing devil's advocate. I'm not sure this would belong in recompose proper anyways |
Too hard to remember all that pathes, defaults etc. Now about types: we overuse dynamic nature of js language, instead of just numbers, strings, structs etc, we use Maybe types, I see your pain with construct above, I have the same, but solving it using magic paths with strings |
...props[propName], | ||
}), | ||
{} | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a "library-like" utility function, maybe it would be worth it to mutate in the reducer. It's ugly, sure, but it performs better:
...propNames.reduce(
(flattenedProps, propName) =>
Object.assign(flattenedProps, props[propName]),
{}
)
If a tree falls in the woods, does it make a sound?
If a pure function mutates some local data in order to produce an immutable return value, is that ok?
— Rich Hickey, Clojure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
every pure function is impure at assembler level - istarkov :-)
I suggest removing
What do you think? |
I don't like the idea of the The good part of FP is that you can compose your function easily. IMO letting the consumers of |
There are many ways in JS to access deeply nested value. The |
@wuct okay. well I'll close this then. just give us a version with deprecation warnings before you remove everything :) |
@alex-wilmer sure! |
I introduced @wuct I got your point, for me FP is the best way, we can compose everything with |
found a need for this when a relay container has multiple fragments.
this would amplify the possibility of prop name collisions, but not any more so than calling
flattenProp
twice.