Open babsonmatt opened 9 years ago
Hah! It sounds like #84 may help. The resolver will bypass any prop that already exists (since it doesn't need resolving).
Can you provide an example?
What I wanted to do in the past was actually having the resolver look at React.PropTypes.foo
and checking for the isRequired
. If it's required, it always resolves. If it's optional, it would not.
I use reselect along with redux, and the issue I'm having is the props returned from reselect/redux may have the key for the object I'm trying to load, but the value of it may be something like an empty object, or null, etc. which means react-resolver won't try to load anything... right? So I'd like to be able to specify a custom function to run to determine if something should be loaded or not, ie: obj.length == 0, etc and not just whether or not the key exists in props.
Ah interesting!
I did consider changing this behavior to do typeof value === "undefined"
.
Would that solve it for you in the interim? The logic is, if the key is undefined
, then it should be resolved.
However, null
is a valid value for resolution. Similarly, an empty object {}
is potentially valid too.
I'm down for coming up with a solution. I just didn't know if undefined
can be set on fields that are...well, undefined :D
Any thoughts on allowing an optional param to be passed to react-resolver to specify when it should actually resolve? I have a situation where just checking whether or not props has a certain key isn't enough and it'd really come in handy to be able to have some custom logic there.
Thanks!