const DMList: FC = () => {
const { workspace } = useParams<{ workspace?: string }>();
const {
data: userData,
error,
revalidate,
mutate,
} = useSWR<IUser>("/api/users", fetcher, {
dedupingInterval: 2000, // 2초
});
const { data: memberData } = useSWR<IUserWithOnline[]>(
userData ? `/api/workspaces/${workspace}/members` : null,
fetcher
);
const [socket] = useSocket(workspace);
const [channelCollapse, setChannelCollapse] = useState(false);
const [countList, setCountList] = useState<{ [key: string]: number }>({});
const [onlineList, setOnlineList] = useState<number[]>([]);
useSocket(workspace)에서
TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
에러가 뜨는데 workspace?: string으로 명시해주었는데 왜 이런 에러가 발생하는건가요? 깃허브에서 똑같이 코드를 가져왔는데도 같은 에러가 발생해서 어떤 점이 문제인지 도무지 알 수가 없어 여쭈어봅니다..ㅠㅠㅠ