{"action":"created","issue":{"url":"https://api.github.com/repos/acdlite/recompose/issues/258","repository_url":"https://api.github.com/repos/acdlite/recompose","labels_url":"https://api.github.com/repos/acdlite/recompose/issues/258/labels{/name}","comments_url":"https://api.github.com/repos/acdlite/recompose/issues/258/comments","events_url":"https://api.github.com/repos/acdlite/recompose/issues/258/events","html_url":"https://github.com/acdlite/recompose/issues/258","id":183449453,"number":258,"title":"Balancing enhancers with simplicity","user":{"login":"grsmvg","id":8234283,"avatar_url":"https://avatars.githubusercontent.com/u/8234283?v=3","gravatar_id":"","url":"https://api.github.com/users/grsmvg","html_url":"https://github.com/grsmvg","followers_url":"https://api.github.com/users/grsmvg/followers","following_url":"https://api.github.com/users/grsmvg/following{/other_user}","gists_url":"https://api.github.com/users/grsmvg/gists{/gist_id}","starred_url":"https://api.github.com/users/grsmvg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grsmvg/subscriptions","organizations_url":"https://api.github.com/users/grsmvg/orgs","repos_url":"https://api.github.com/users/grsmvg/repos","events_url":"https://api.github.com/users/grsmvg/events{/privacy}","received_events_url":"https://api.github.com/users/grsmvg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-17T15:31:48Z","updated_at":"2016-10-17T16:01:49Z","closed_at":null,"body":"I like recompose a lot, but I'm struggling with where I should stop using enhancers en just put stuff inside normal classes / function components.\r\n\r\nLet's say we have this fictional component, (using MomentJS). It displays a month name and day numbers, given the first day of the week:\r\n```\r\n// Imports...\r\n\r\nconst Week = props =>\r\n  <div>\r\n    <div className=\"monthName\">\r\n      {props.days[6].format('MMM').toUpperCase()}\r\n    </div>\r\n    <div className=\"days\">\r\n      {props.days.map(day =>\r\n        <div className=\"day\">\r\n          day.format('D')\r\n        </div>\r\n      )}\r\n    </div>\r\n  </div>\r\n\r\nconst enhance = compose(\r\n  setPropTypes({\r\n    firstDay: momentPT.momentObj.isRequired,\r\n  }),\r\n  shouldUpdate((props, nextProps) =>\r\n    !props.firstDay.isSame(nextProps.firstDay, 'day')\r\n  ),\r\n  mapProps(props => ({\r\n    days: range(7).map(n => props.firstDay.clone().add(n, 'day')),\r\n  }))\r\n)\r\n\r\nexport enhance(Week)\r\n```\r\n\r\n\r\nInstead, I could also add an additional withProps. Or am I taking this to the extreme?\r\n```\r\n  setPropTypes(...),\r\n  shouldUpdate(...),\r\n  mapProps(...),\r\n  withProps(props => ({ monthName: props.days[6].format('MMM').toUpperCase() }))\r\n\r\nand then:\r\n\r\n  <div className=\"monthName\">\r\n    {props.monthName}\r\n  </div>\r\n```\r\n\r\nAnd what about setPropTypes: should you define them always after usage of map/withProps? Or use them only for those props of which the values are calculated/obtained from outside of the component file ( JSX props, Redux connect() ). I like the latter, because otherwise you often have to define several setPropTypes within the same compose()."},"comment":{"url":"https://api.github.com/repos/acdlite/recompose/issues/comments/254251351","html_url":"https://github.com/acdlite/recompose/issues/258#issuecomment-254251351","issue_url":"https://api.github.com/repos/acdlite/recompose/issues/258","id":254251351,"user":{"login":"grsmvg","id":8234283,"avatar_url":"https://avatars.githubusercontent.com/u/8234283?v=3","gravatar_id":"","url":"https://api.github.com/users/grsmvg","html_url":"https://github.com/grsmvg","followers_url":"https://api.github.com/users/grsmvg/followers","following_url":"https://api.github.com/users/grsmvg/following{/other_user}","gists_url":"https://api.github.com/users/grsmvg/gists{/gist_id}","starred_url":"https://api.github.com/users/grsmvg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grsmvg/subscriptions","organizations_url":"https://api.github.com/users/grsmvg/orgs","repos_url":"https://api.github.com/users/grsmvg/repos","events_url":"https://api.github.com/users/grsmvg/events{/privacy}","received_events_url":"https://api.github.com/users/grsmvg/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T16:01:49Z","updated_at":"2016-10-17T16:01:49Z","body":"> But this is not a rule, sometimes I can move all into render, or all into enhancer.\r\nThere are no performance issues when using multiple map/withProps in a row (with other enhancers in between)? Is this also where component squashing comes into play?\r\n\r\n> About setPropTypes - I prefer not to use them at all, as not a lot bugs could be found/created without that checks IMO.\r\nI guess we have different coding styles then 😃. I tend to mess around with my Redux state structure and forget about that small component somewhere that also depends on the structure. They saved me already a lot of times."}}
{"actor":{"display_login":"grsmvg"}}