-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added recursive pick for withPropsOnChange feature #300
Conversation
]), | ||
{ | ||
one: '1', | ||
'two\ndeep\nvalue': 'true', |
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.
Seperator could be changed if we don't like the new line but property names probably won't include new lines (that is why I choose that character).
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.
Also if we don't like this solution we could do this with a Map
but then we have to add a new shallowEqual
that supports Map
.
}, [ | ||
'one', | ||
['two', 'deep', 'value'], | ||
['root', 'missed'], |
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.
If we try to go deeper ['root', 'missed', 'something']
would still return undefined
.
Hi, thank you! Why not just use something like Also, I think that even I was one of the persons who saved this enhancer comment it's mostly overused. I used it in every component I did, but now it's very rare enhancer in my code, javascript and React are fast enough to use it only in real "computational intensive" tasks. (Can say that such tasks are very rare in our codebase) Also I dislike all that string getters in the code like So from my POV we should not create or extend features non possible in strongly typed languages. PS: In my code I very rare use version of And write |
withProps(({ router: { routeParams: { something } } }) => ({ something })) Will fail if either |
Will not fail as you can use defaults for args
…On Jan 5, 2017 14:06, "Olle Bröms" ***@***.***> wrote:
withProps(({ router: { routeParams: { something } } }) => ({ something }))
Will fail if either router or routeParams. Sorry for short comment
written on mobile 😁
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#300 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE14MnbAgIavRqF2TdcWv3z2WjNk1kYBks5rPM7EgaJpZM4La06x>
.
|
So I need 3 types of hocs then? That I will also call bloating the code 😂 |
The current signature of
I believe you meant using If it's still not good enough to you, one of the beauty of FP is that you can always compose a new function easily. Without changing the behavior of |
@wuct So you also want another dependency? I don't like to have 1 000 000 dependencies in my Default parameters in this case that is very common looks totally ugly and hard to read. withPropsOnChange(
(
{ router: { params: { something } = {} } = {} },
{ router: { params: { something: newSomething } = {} } = {} }
) => {
// This example is for one prop. Think how multiple properties will look!
}
) |
@istarkov About that fetch claim. There are other ways of solving that. I often use |
Why pick does not support dot notation like lodash? it would be useful for onlyUpdateForKeys for example. |
Hi
First of all I would like to thank you for this awesome library!
I often use the
withPropsOnChange
but I miss the functionality to listen for nested properties and writing functions looks totally ugly. So I came up with this.The code looks even more ugly if the
routeParams
isn't defined with current implementation. You then need to have checks if it exists that bloats the code.With my feature request you can replace this with: