File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
client/src/components/WorkspaceList Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1- import { memo , useEffect , useState } from 'react' ;
1+ import { memo , useContext , useEffect , useState } from 'react' ;
22import { getWorkspaces } from 'src/apis/user' ;
3+ import UserContext from 'src/contexts/user' ;
34import { Workspace } from 'src/types/workspace' ;
45
56import AddButton from './AddButton' ;
@@ -12,18 +13,18 @@ interface WorkspaceListProps {
1213
1314function WorkspaceList ( { onSelectModalOpen } : WorkspaceListProps ) {
1415 const [ workspaces , setWorkspaces ] = useState < Workspace [ ] > ( [ ] ) ;
15- /**
16- * 나중에 login하고 context생기면 바꿔 끼우면 돼요.
17- */
18- const userId = 63814960 ;
16+ const userContext = useContext ( UserContext ) ;
1917
2018 const updateWorkspaces = async ( userId : number ) => {
2119 const { workspaces } = await getWorkspaces ( userId ) ;
2220 setWorkspaces ( workspaces ) ;
2321 } ;
2422
2523 useEffect ( ( ) => {
26- updateWorkspaces ( userId ) ;
24+ if ( ! userContext ) {
25+ return ;
26+ }
27+ updateWorkspaces ( userContext . user . id ) ;
2728 } , [ ] ) ;
2829
2930 return (
You can’t perform that action at this time.
0 commit comments