Replies: 1 comment 4 replies
-
|
Thanks for sharing ideas. At the base, it's our design decision not to rerender at the component level (at least for now). What we do is page/layout/slice level rendering. As I understand it, the request is to selectively rerender some of dynamic page/layout/slices. It's probably a new render type besides "static" and "dynamic". It's reasonable to consider. Though, if it's an additional API that doesn't conflict with current design, I think I'd consider after v1 is released. Meantime, let's discuss about how the API would look like. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal: Component-Level Re-rendering in Waku
Problem Statement
Currently,
unstable_rerenderRoute()triggers a full page re-render, including layout components. This is inefficient when only a specific page component needs to update after a server action, especially when:Use Case: Form Submission in Nested Layout Structure
Consider a typical Waku application structure:
Current Behavior
When
unstable_rerenderRoute('/guess')is called:Guess) re-renders on serverAppLayout) also re-renders on server (unnecessary)Problem: Layout components that haven't changed are still re-rendered and sent over the wire.
Proposed Solution
Add a new API
unstable_rerenderComponent()that re-renders only the current page component within its layout.API Design
Behavior
When
unstable_rerenderComponent()is called from within a page component:Example Usage
Implementation Considerations
1. Component Context Tracking
The framework needs to track which component invoked the re-render:
2. Layout Component Caching
Layout components should use their cached render when a child component re-renders:
3. Context Data Scope
Context data (
getContextData()) should remain request-scoped and accessible to both layout and page components during re-render, but layout components won't execute unless they explicitly need to.4. Error Handling
If
unstable_rerenderComponent()is called from outside a page component:Benefits
Example: Before and After
Before (Current)
After (Proposed)
Open Questions
Conclusion
This proposal adds a focused API for component-level re-rendering that improves performance and developer experience while maintaining backward compatibility. The use case demonstrates a common pattern where page components update frequently while layouts remain static, making this optimization valuable for real-world applications.
Beta Was this translation helpful? Give feedback.
All reactions