Details
- Reviewers
michal inka - Commits
- rCOMMb19e1f9e521e: [web] Changed edit modal overlay opacity
Checked if new opacity is applied in edit mode. Checked if it is not applied in other modals.
Diff Detail
- Repository
- rCOMM Comm
- Branch
- kuba/message-editing-web
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
lib/components/modal-overlay.react.js | ||
---|---|---|
59 | This should be memoized. By passing in this new object every time, you've actually made all of the memoization above completely useless (memoization of onBackgroundMouseDown, onBackgroundMouseUp, and onKeyDown is now useless) |
Can you remove the color from modal-overlay.css and set the default in ModalOverlay? I feel this will be more readable.
lib/components/modal-overlay.react.js | ||
---|---|---|
59 ↗ | (On Diff #26889) | Shorthand |
You don't need to use React.useMemo(...) here.
The useMemo() hook is helpful for maintaining referential equality so that objects will be considered "shallowly equal" (== in JS) and we can avoid re-renders. This is helpful for objects (including Map(), Set(), etc), arrays (which are objects), and functions (which are objects).
On the other hand, strings in JS are considered shallowly equal if they have the same contents, so we don't have to worry about re-renders if the "content" stays the same.
See below:
(In like C++, which you've been working w/ recently, std::strings can be allocated on the heap (unlike integers, booleans, etc) which may have been part of your reasoning that shallow equality would check reference instead of contents?)