In my hoc I have this conditional;
branch(R.propSatisfies(R.isEmpty, "repos"), renderComponent(Loader)),
// branch(R.isEmpty("repos"), renderComponent(Loader)),
What's the difference and why the socond one gives me an error? test is not a function
Same result with this as well:
branch(R.isEmpty(R.props("repos")), renderComponent(Loader)),
R. IsEmpty
is unary function that reports whether a value is the empty value for its type (such as empty string, empty object, or empty array.). When you call it with "repos"
, you will get false
since "repos"
is not the empty string. Presumably the branch
function you call wants a predicate function as the first argument and it fails when you send this boolean. Similarly, since R. props
(you probably meant R.prop
BTW, but the same issue would apply) is a binary function, R.props("repos")
returns a function, which is not empty, so isEmpty
returns false.
R.propSatisfies
, on the other hand, is a ternary function accepting a predicate function, a property name, and an object. When you call it with isEmpty
and "repos"
, you get back a function waiting for the object. That gets passed to branch
and all is good.
Is there a reason you don't like the propSatisfies
version?