Adding a selector that fetches the id of the community currently picked in Chat tab
issue: https://linear.app/comm/issue/ENG-3176/make-pressing-a-drawer-item-in-chat-tab-filter-available-chats
Details
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
web/selectors/thread-selectors.js | ||
---|---|---|
111 | I'm not a big fan of creating such simple hooks - feels like it adds a useless boilerplate to the code. It can easily be done as a simple selector, and it's used only once looking through this stack, but I think I've seen one-line hooks like this in the codebase, so probably it's okay 😄 On the other hand in D6974 (ChatDrawerItemCommunityHandler) you used a selector, not this hook. I'm curious about what other reviewers think about this pattern (cc. @tomek) |
web/selectors/thread-selectors.js | ||
---|---|---|
111 | This one is indeed really simple. Possible benefits of having simple selectors include:
The downside is that this type of selector, which is a hook, can't be efficiently composed. If instead only the state => data function was extracted, we could efficiently compose it in e.g. createSelector. But that usually doesn't matter at all. So overall, I think it is ok to have simple selectors, but only when they can be named well. It's also ok to select by hand. If the selector is more complicated, extracting it makes more sense. |
I still prefer selecting by hand, but this approach is also correct
web/selectors/thread-selectors.js | ||
---|---|---|
111 | Thanks for the thorough response! |
I will think this through. Since I wrote this, some similar selectors were written (be me), and I would like to either unify them a bit or remove some of them. I will follow up next week