0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Reactでの名前空間インポート

Posted at

「このフォルダ(モジュール)のものたち」を、Form.xxx みたいに“名字付き”で扱えるようにするのが名前空間インポートのメリット

React での名前空間インポート:

import * as Form from "@/components/form";

<Form.InputField ... />
<Form.SelectField ... />

メリット

  • “どこから来たコンポーネントか” が一目でわかる
  • 名前衝突を避けやすい(Button が何個あっても怖くない)
  • バレルファイル(index.ts)と組み合わせると「モジュール境界」がわかりやすくなる
  • 大きめフォームなどで 「Form.」「Layout.」のように役割ごとに整理して読める
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?