Today I Learned

hashrocket A Hashrocket project

React Activity component

Today I learned about React 19.2’s new <Activity> component.

<Activity mode={isShowingSidebar ? "visible" : "hidden"}>
  <Sidebar />
</Activity>

When mode="hidden", React unmounts all useEffect, it keeps state cached and yet the DOM stays rendered via display: none.

Switching back to mode="visible" restores the view instantly with its previous state and fire all useEffect again.

This is perfect for tabs, modals, and any UI you want ready-to-go.

reference: React Activity docs

See More #react TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.