Skip to content
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

Merged
merged 7 commits into from
Feb 7, 2025

Conversation

appare45
Copy link
Member

@appare45 appare45 commented Feb 7, 2025

Storybookを作るに当たり、コンポーネントからSWRを使う(バックエンドにリクエストする)とクレデンシャルが必要になってしまうので、それを避けるためにコンポーネントないで使うデータに関しては基本的に外部からpropsで渡すように変更した

Copy link

cloudflare-workers-and-pages bot commented Feb 7, 2025

Deploying sos24-client with  Cloudflare Pages  Cloudflare Pages

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

View logs

@appare45 appare45 self-assigned this Feb 7, 2025
@appare45 appare45 requested a review from a team February 7, 2025 11:19
@appare45 appare45 changed the title リファクタリング コンポーネントからuseSWRを使うのを減らす Feb 7, 2025
Comment on lines +92 to -99
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userInfoをporpsから渡すように変更

Comment on lines +9 to +15
export type Props = {
menu: MenuData[];
path: any;
userInfo: components["schemas"]["User"];
};

export const HeaderNavigationMobile: FC<Props> = ({ menu, path, userInfo }) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userInfoをPropsから渡すように変更した

Comment on lines +8 to +13
export type Props = {
file: components["schemas"]["File"];
error?: components["schemas"]["Error"];
};

export const FileItem: FC<Props> = ({ file, error }) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileがpropsに渡されない

Copy link
Member

@masebb masebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赤入れOKです

@masebb masebb merged commit db9859c into develop Feb 7, 2025
4 checks passed
@masebb
Copy link
Member

masebb commented Feb 7, 2025

LGTMeow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants