By default, Reflex will re-render the entire page every time the state changes. This is fine for small apps, but can be slow for larger apps.
You can prevent unnecessary rendering by memoizing components, which can greatly improve your app's performance. Just add the @rx.memo decorator to a component function to make it memoized, and list its props as arguments.
Only components that don't depend on the state can be memoized.
Memoized components aren't re-rendered when the state changes.
The memoized component can be used like any other component. Use keyword arguments to pass in the component's props.
This Heading Won't Rerender
@rx.memodeffixed_header(text:str)-> rx.Component:"""A fixed header that doesn't change when the state changes."""return rx.heading(text)defindex():return fixed_header(text="This Heading Won't Rerender")