[PR #3718] fix: toggling AppDetailNav causes unnecessary component rerenders #24248

Closed
opened 2026-02-21 20:22:39 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/3718

State: closed
Merged: Yes


Description

When a state selector is not set, the component will render on every state change. Even if only extracting a specific state field using object destructuring, it will still respond to all state changes. This will cause some unnecessary component rerenders.

// no
const state = useAppStore()
// no
const { appDetail } = useAppStore()
// yes
const appDetail = useAppStore(state => state.appDetail)

create or createStore

The store created with create doesn't require context providers. In some cases, you may want to use contexts for dependency injection or if you want to initialize your store with props from a component. Because the normal store is a hook, passing it as a normal context value may violate the rules of hooks.

Type of Change

  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
**Original Pull Request:** https://github.com/langgenius/dify/pull/3718 **State:** closed **Merged:** Yes --- # Description When a state selector is not set, the component will render on every state change. Even if only extracting a specific state field using object destructuring, it will still respond to all state changes. This will cause some unnecessary component rerenders. ```ts // no const state = useAppStore() // no const { appDetail } = useAppStore() // yes const appDetail = useAppStore(state => state.appDetail) ``` `create` or `createStore` > The store created with create doesn't require context providers. In some cases, you may want to use contexts for dependency injection or if you want to initialize your store with props from a component. Because the normal store is a hook, passing it as a normal context value may violate the rules of hooks. ## Type of Change - [x] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
yindo added the pull-request label 2026-02-21 20:22:39 -05:00
yindo closed this issue 2026-02-21 20:22:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#24248