-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: TabsProvider 구현 * refactor: Tabs 컨텍스트로 변경 * refactor: 탭 타입 지정 * refactor: 훅 이름 변경
- Loading branch information
Showing
10 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PropsWithChildren, useState } from 'react' | ||
import { TabsContext } from '@/contexts' | ||
import { Tabs } from '@/types' | ||
|
||
const TabsProvider = ({ children }: PropsWithChildren) => { | ||
const [activeTab, setActiveTab] = useState<Tabs>('invited') | ||
|
||
return ( | ||
<TabsContext.Provider value={{ activeTab, setActiveTab }}> | ||
{children} | ||
</TabsContext.Provider> | ||
) | ||
} | ||
|
||
export default TabsProvider |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Dispatch, SetStateAction, createContext } from 'react' | ||
import { Tabs } from '@/types' | ||
|
||
interface TabsContextType { | ||
activeTab: Tabs | ||
setActiveTab: Dispatch<SetStateAction<Tabs>> | ||
} | ||
|
||
const TabsContext = createContext<TabsContextType>({ | ||
activeTab: 'invited', | ||
setActiveTab: () => {}, | ||
}) | ||
|
||
export default TabsContext |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as ThemeContext } from './ThemeContext' | ||
export { default as ToastContext } from './ToastContext' | ||
export { default as TabsContext } from './TabsContext' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useContext } from 'react' | ||
import { TabsContext } from '@/contexts' | ||
|
||
const useTabs = () => { | ||
return useContext(TabsContext) | ||
} | ||
|
||
export default useTabs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './reviews' | ||
export * from './reviewDetailed' | ||
export * from './tabs' |
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 @@ | ||
export type Tabs = 'invited' | 'created' | 'received' |