For consistency with the existing MarkdownLink component in
native, refactoring Spoiler to MarkdownSpoiler and putting it in the same
directory native/markdown/... makes the most sense. This is Step 2 in
ENG-2072
(https://linear.app/comm/issue/ENG-2072/maintain-the-spoiler-state-upon-opening-textmessagetooltipmodal).
Details
Spoiler text still works as expected, and they are revealed on
click.
Diff Detail
- Repository
- rCOMM Comm
- Branch
- spoiler
- Lint
No Lint Coverage - Unit
No Test Coverage
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?)