I use the following function to send some data to a React component by wrapping it in a higher-order component:
import { equals, filter, isNil, prop, where } from 'ramda'
const example = getChapter => ownProps =>
filter(
where({
sectionId: equals(prop('section', ownProps)),
subsectionId: isNil,
sub2sectionId: isNil,
sub3sectionId: isNil
}),
prop('getContents', getChapter)
)
I’m familiar with the concepts of functional programming, but still relatively new to the Ramda library. Now I’d like to rewrite this code using Ramda so that ownProps
and getChapter
can get eliminated, if only as an academic exercise.
It seems like I should eliminate ownProps
first because of the order of the arguments? Although I’m not even sure of that.
Any help would be greatly appreciated!
PS. I’m aware that in the code above ownProps.section
would be more readable and preferred to prop('section', ownProps)
, ceteri paribus, but I expect that the prop
function lies on the path to a point-free equivalent of the code above, hence their inclusion.