const updatePage = (
pageId: string,
updates: { title?: string; icon?: string },
syncWithServer: boolean = true,
) => {
setPages((prevPages) =>
prevPages.map((page) => (page.id === pageId ? { ...page, ...updates } : page)),
);
if (syncWithServer && clientId && workspace?.id) {
sendPageUpdateOperation({
pageId,
...updates,
clientId,
workspaceId: workspace.id,
});
}
};
const updatePage = (
pageId: string,
updates: { title?: string; icon?: string },
syncWithServer: boolean = true,
) => {
setPages((prevPages) =>
prevPages.map((page) => (page.id === pageId ? { ...page, ...updates } : page)),
);
if (syncWithServer && clientId && workspace!.id) {
sendPageUpdateOperation({
pageId,
...updates,
clientId,
workspaceId: workspace!.id,
});
}
};
!
을 사용하면,TypeScript에게 명확하게 "이 값은 반드시 존재한다"고 알려줍니다.
신기하다…!