Fix/rerender lazy state init#10475
Conversation
|
|
📝 WalkthroughWalkthroughSix React components convert their ChangesLazy useState initializer conversions
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
recheck |
|
@pavinduLakshan Could you please review this |
Purpose
Fix performance issue where useState initial values were being re-evaluated on every render instead of only once on mount. closes wso2/product-is#27955 (comment)
React evaluates a plain expression passed to useState(expr) on every render (the result is discarded after the first render, but the computation still runs). Wrapping it as useState(() => expr) changes to a lazy initializer pattern ensuring the function is called only once during component mount.
Fixed in 6 files:
admin.claims.v1 — getExcludedStoresFromClaim(claim) (array computation from claim data)
admin.console-settings.v1 — getActiveTabFromUrl() (URL parsing)
admin.login-flow-builder.v1 — cloneDeep(application?.authenticationSequence) (deep object clone)
admin.logs.v1 — getCurrentTimeZone() (timezone lookup)
admin.org-insights.v1 — dayjs().format("HH:mm:ss") (date formatting)
admin.tenants.v1 — getActiveTabFromUrl() (URL parsing)
Related Issues
Related PRs
Checklist
Security checks
Developer Checklist (Mandatory)
product-isissue to track any behavioral change or migration impact.