LoginSignup
1
0

More than 1 year has passed since last update.

React のコンポーネントでは、名前付きエクスポートを利用すると良い

Last updated at Posted at 2022-04-17

結論

基本的に React のコンポーネントでは、名前付きエクスポートを利用すると良い。

理由

  • 名前付きエクスポートは、インポートするのに正確な名前を使うことを強制するため。
  • デフォルトエクスポートは、独自の名前を作成する必要があり、誤用される恐れがあるため。

名前付きエクスポート

export const SomeComponent = () => {};
import { SomeComponent } from './SomeComponent';

デフォルトエクスポート

const SomeComponent = () => {};
export default SomeComponent;
import Some from './SomeComponent';

参考

1
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
1
0