-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
コンポーネントからuseSWRを使うのを減らす #459
Conversation
Deploying sos24-client with
|
Latest commit: |
1e35ee2
|
Status: | ✅ Deploy successful! |
Preview URL: | https://fe257c0e.sos24-client.pages.dev |
Branch Preview URL: | https://improve-refactor-components.sos24-client.pages.dev |
type Props = { | ||
userIsLoading: boolean; | ||
userInfo?: components["schemas"]["User"]; | ||
}; | ||
|
||
export const Header: FC<Props> = ({ userInfo, userIsLoading }) => { | ||
const router = useRouter(); | ||
const { user, isLoading } = useAuthState(); | ||
const auth = getAuth(); | ||
const { data: userRes, isLoading: userIsLoading } = useSWR("/users/me"); | ||
const userInfo = !userIsLoading ? assignType("/users/me", userRes) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userInfoをporpsから渡すように変更
export type Props = { | ||
menu: MenuData[]; | ||
path: any; | ||
userInfo: components["schemas"]["User"]; | ||
}; | ||
|
||
export const HeaderNavigationMobile: FC<Props> = ({ menu, path, userInfo }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userInfoをPropsから渡すように変更した
export type Props = { | ||
file: components["schemas"]["File"]; | ||
error?: components["schemas"]["Error"]; | ||
}; | ||
|
||
export const FileItem: FC<Props> = ({ file, error }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileがpropsに渡されない
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赤入れOKです
Storybookを作るに当たり、コンポーネントからSWRを使う(バックエンドにリクエストする)とクレデンシャルが必要になってしまうので、それを避けるためにコンポーネントないで使うデータに関しては基本的に外部からpropsで渡すように変更した