-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: GroupChannelList migration (#1231)
### Changelogs This is a part of state management migration. This PR migrate 'GroupChannelListProvider' and related files to the new style. * Created `useGroupChannelList()` hook. It'll replace the previous `useGroupChannelContext()` hook.
- Loading branch information
1 parent
f05158f
commit 7313618
Showing
5 changed files
with
143 additions
and
44 deletions.
There are no files selected for viewing
10 changes: 8 additions & 2 deletions
10
src/modules/GroupChannelList/components/AddGroupChannel/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/modules/GroupChannelList/context/useGroupChannelList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { GroupChannelListState, useGroupChannelListContext } from './GroupChannelListProvider'; | ||
import { useSyncExternalStore } from 'use-sync-external-store/shim'; | ||
import { useMemo } from 'react'; | ||
|
||
export const useGroupChannelList = () => { | ||
const store = useGroupChannelListContext(); | ||
if (!store) throw new Error('useChannelSettings must be used within a ChannelSettingsProvider'); | ||
|
||
const state: GroupChannelListState = useSyncExternalStore(store.subscribe, store.getState); | ||
const actions = useMemo(() => ({ | ||
}), [store]); | ||
|
||
return { state, actions }; | ||
}; |