Fix rerender bug with followed hashtag parent

And… somehow memoize it?
This commit is contained in:
Lim Chee Aun 2024-04-15 21:37:03 +08:00
parent 9a6364a674
commit a68dccd7cf

View file

@ -407,26 +407,29 @@ function Status({
} }
// Check followedTags // Check followedTags
const FollowedTagsParent = ({ children }) => ( const FollowedTagsParent = useCallback(
<div ({ children }) => (
data-state-post-id={sKey} <div
class="status-followed-tags" data-state-post-id={sKey}
onMouseEnter={debugHover} class="status-followed-tags"
> onMouseEnter={debugHover}
<div class="status-pre-meta"> >
<Icon icon="hashtag" size="l" />{' '} <div class="status-pre-meta">
{snapStates.statusFollowedTags[sKey].slice(0, 3).map((tag) => ( <Icon icon="hashtag" size="l" />{' '}
<Link {snapStates.statusFollowedTags[sKey].slice(0, 3).map((tag) => (
key={tag} <Link
to={instance ? `/${instance}/t/${tag}` : `/t/${tag}`} key={tag}
class="status-followed-tag-item" to={instance ? `/${instance}/t/${tag}` : `/t/${tag}`}
> class="status-followed-tag-item"
{tag} >
</Link> {tag}
))} </Link>
))}
</div>
{children}
</div> </div>
{children} ),
</div> [sKey, instance, snapStates.statusFollowedTags[sKey]],
); );
const StatusParent = const StatusParent =
showFollowedTags && !!snapStates.statusFollowedTags[sKey]?.length showFollowedTags && !!snapStates.statusFollowedTags[sKey]?.length